github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/depends/kit/enumgen/scanner_test.go (about) 1 package enumgen_test 2 3 import ( 4 "os" 5 "path/filepath" 6 "testing" 7 8 . "github.com/onsi/gomega" 9 10 "github.com/machinefi/w3bstream/pkg/depends/kit/enumgen" 11 "github.com/machinefi/w3bstream/pkg/depends/x/pkgx" 12 ) 13 14 func TestScanner(t *testing.T) { 15 cwd, _ := os.Getwd() 16 p, _ := pkgx.LoadFrom(filepath.Join(cwd, "./__examples__")) 17 18 g := enumgen.New(p) 19 20 t.Run("ScanIntStringerEnum", func(t *testing.T) { 21 options, ok := g.Options(p.TypeName("Scheme")) 22 NewWithT(t).Expect(ok).To(BeTrue()) 23 24 NewWithT(t).Expect(options.Len()).To(Equal(5)) 25 NewWithT(t).Expect(*options[0].Str).To(Equal("HTTP")) 26 NewWithT(t).Expect(*options[2].Str).To(Equal("TCP")) 27 }) 28 29 t.Run("ScanStringEnum", func(t *testing.T) { 30 options, ok := g.Options(p.TypeName("PullPolicy")) 31 NewWithT(t).Expect(ok).To(BeTrue()) 32 33 NewWithT(t).Expect(options.Len()).To(Equal(3)) 34 NewWithT(t).Expect(*options[0].Str).To(Equal("Always")) 35 NewWithT(t).Expect(*options[2].Str).To(Equal("Never")) 36 }) 37 }