github.com/cybriq/giocore@v0.0.7-0.20210703034601-cfb9cb5f3900/cmd/gogio/build_info_test.go (about) 1 package main 2 3 import "testing" 4 5 type expval struct { 6 in, out string 7 } 8 9 func TestAppID(t *testing.T) { 10 t.Parallel() 11 12 tests := []expval{ 13 {"example", "localhost.example"}, 14 {"example.com", "com.example"}, 15 {"www.example.com", "com.example.www"}, 16 {"examplecom/app", "examplecom.app"}, 17 {"example.com/app", "com.example.app"}, 18 {"www.example.com/app", "com.example.www.app"}, 19 {"www.en.example.com/app", "com.example.en.www.app"}, 20 {"example.com/dir/app", "com.example.app"}, 21 {"example.com/dir.ext/app", "com.example.app"}, 22 {"example.com/dir/app.ext", "com.example.app.ext"}, 23 {"example-com.net/dir/app", "net.example_com.app"}, 24 } 25 26 for i, test := range tests { 27 got := getAppID(&packageMetadata{PkgPath: test.in}) 28 if exp := test.out; got != exp { 29 t.Errorf("(%d): expected '%s', got '%s'", i, exp, got) 30 } 31 } 32 }