๐พ Archived View for source.community โบ ckaznocha โบ gemini โบ blob โบ main โบ url_test.go captured on 2023-04-26 at 13:24:37. 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 /url_test.go (main)
โโโโโฎ 1โ package gemini_test 2โ 3โ import ( 4โ "testing" 5โ 6โ "source.community/ckaznocha/gemini" 7โ ) 8โ 9โ func TestParseRequestURI(t *testing.T) { 10โ t.Parallel() 11โ 12โ type args struct { 13โ rawURI string 14โ } 15โ 16โ tests := []struct { 17โ want *gemini.URI 18โ name string 19โ args args 20โ wantErr bool 21โ }{ 22โ { 23โ name: "", 24โ args: args{"gemini://example.com"}, 25โ want: &gemini.URI{ 26โ Host: "example.com", 27โ }, 28โ wantErr: false, 29โ }, 30โ { 31โ name: "url must be absolute", 32โ args: args{"/foo/bar"}, 33โ wantErr: true, 34โ }, 35โ { 36โ name: "url cannot have a user", 37โ args: args{"gemini://foo:bar@example.com"}, 38โ wantErr: true, 39โ }, 40โ { 41โ name: "url cannot be relative", 42โ args: args{"gemini:/foo/bar"}, 43โ wantErr: true, 44โ }, 45โ { 46โ name: "url must be valid", 47โ args: args{"--()"}, 48โ wantErr: true, 49โ }, 50โ } 51โ 52โ for _, tt := range tests { 53โ tt := tt 54โ t.Run(tt.name, func(t *testing.T) { 55โ t.Parallel() 56โ got, err := gemini.ParseRequestURI(tt.args.rawURI) 57โ if (err != nil) != tt.wantErr { 58โ t.Errorf("ParseRequestURI() error = %v, wantErr %v", err, tt.wantErr) 59โ 60โ return 61โ } 62โ 63โ if !tt.wantErr && got.String() != tt.want.String() { 64โ t.Errorf("ParseRequestURI() = %v, want %v", got, tt.want) 65โ } 66โ }) 67โ } 68โ } โโโโโฏ
ยท ยท ยท
ยฉ 2023 source.community