๐พ Archived View for source.community โบ ckaznocha โบ gemini โบ blob โบ main โบ request_test.go captured on 2023-07-10 at 13:30:26. Gemini links have been rewritten to link to archived content
โฌ ๏ธ Previous capture (2023-01-29)
โก๏ธ Next capture (2024-02-05)
-=-=-=-=-=-=-
. ,-. ,-. . . ,-. ,-. ,-. ,-. ,-. ,-,-. ,-,-. . . ,-. . |- . . `-. | | | | | | |-' | | | | | | | | | | | | | | | | | `-' `-' `-^ ' `-' `-' :: `-' `-' ' ' ' ' ' ' `-^ ' ' ' `' `-| /| `-'
git clone https://source.community/ckaznocha/gemini.git
View raw contents of /request_test.go (main)
โโโโโฎ 1โ package gemini_test 2โ 3โ import ( 4โ "bufio" 5โ "reflect" 6โ "strings" 7โ "testing" 8โ 9โ "source.community/ckaznocha/gemini" 10โ ) 11โ 12โ func TestReadRequest(t *testing.T) { 13โ t.Parallel() 14โ 15โ type args struct { 16โ b *bufio.Reader 17โ } 18โ 19โ tests := []struct { 20โ args args 21โ want *gemini.Request 22โ name string 23โ wantErr bool 24โ }{ 25โ // { 26โ // name: "", 27โ // args: args{ 28โ // b: bufio.NewReader(strings.NewReader("gemini://example.com/\r\n")), 29โ // }, 30โ // want: &gemini.Request{ 31โ // URI: &gemini.URI{ 32โ // Query: map[string][]string{}, 33โ // Host: "example.com", 34โ // Port: "", 35โ // Path: "/", 36โ // Fragment: "", 37โ // RawQuery: "", 38โ // }, 39โ // RemoteAddr: "", 40โ // Subject: nil, 41โ // }, 42โ // wantErr: false, 43โ // }, 44โ { 45โ name: "malformed request errors", 46โ args: args{ 47โ b: bufio.NewReader(strings.NewReader("gemini://example.com/")), 48โ }, 49โ wantErr: true, 50โ }, 51โ { 52โ name: "request too long errors", 53โ args: args{ 54โ b: bufio.NewReader(strings.NewReader("gemini://example.com/" + strings.Repeat("a", 1024) + "\r\n")), 55โ }, 56โ wantErr: true, 57โ }, 58โ { 59โ name: "invalid URI errors", 60โ args: args{ 61โ b: bufio.NewReader(strings.NewReader("/foo\r\n")), 62โ }, 63โ wantErr: true, 64โ }, 65โ } 66โ 67โ for _, tt := range tests { 68โ tt := tt 69โ t.Run(tt.name, func(t *testing.T) { 70โ t.Parallel() 71โ got, err := gemini.ReadRequest(tt.args.b) 72โ if (err != nil) != tt.wantErr { 73โ t.Errorf("ReadRequest(%v) error = %v, wantErr %v", tt.args.b, err, tt.wantErr) 74โ 75โ return 76โ } 77โ if !reflect.DeepEqual(got, tt.want) { 78โ t.Errorf("ReadRequest(%v) = %v, want %v", tt.args.b, got, tt.want) 79โ } 80โ }) 81โ } 82โ } โโโโโฏ
ยท ยท ยท
ยฉ 2023 source.community