💾 Archived View for source.community › ckaznocha › gemini › raw › main › url_test.go captured on 2021-12-17 at 13:26:06.
-=-=-=-=-=-=-
package gemini_test import ( "testing" "source.community/ckaznocha/gemini" ) func TestParseRequestURI(t *testing.T) { t.Parallel() type args struct { rawURI string } tests := []struct { want *gemini.URI name string args args wantErr bool }{ { name: "", args: args{"gemini://example.com"}, want: &gemini.URI{ Host: "example.com", }, wantErr: false, }, { name: "url must be absolute", args: args{"/foo/bar"}, wantErr: true, }, { name: "url cannot have a user", args: args{"gemini://foo:bar@example.com"}, wantErr: true, }, { name: "url cannot be relative", args: args{"gemini:/foo/bar"}, wantErr: true, }, { name: "url must be valid", args: args{"--()"}, wantErr: true, }, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := gemini.ParseRequestURI(tt.args.rawURI) if (err != nil) != tt.wantErr { t.Errorf("ParseRequestURI() error = %v, wantErr %v", err, tt.wantErr) return } if !tt.wantErr && got.String() != tt.want.String() { t.Errorf("ParseRequestURI() = %v, want %v", got, tt.want) } }) } }