github.com/replicatedhq/ship@v0.55.0/pkg/ship/dig_test.go (about) 1 package ship 2 3 import ( 4 "testing" 5 6 "github.com/spf13/viper" 7 "github.com/stretchr/testify/require" 8 ) 9 10 // Make sure we can get an instance of ship 11 func TestDI(t *testing.T) { 12 tests := []struct { 13 name string 14 set map[string]bool 15 }{ 16 { 17 name: "headless+navcycle", 18 set: map[string]bool{ 19 "headless": true, 20 "navcycle": true, 21 }, 22 }, 23 { 24 name: "headless", 25 set: map[string]bool{ 26 "headless": true, 27 "navcycle": false, 28 }, 29 }, 30 { 31 name: "navcycle", 32 set: map[string]bool{ 33 "headless": false, 34 "navcycle": true, 35 }, 36 }, 37 { 38 name: "headed", 39 set: map[string]bool{ 40 "headless": false, 41 "navcycle": false, 42 }, 43 }, 44 } 45 46 for _, test := range tests { 47 t.Run(test.name, func(t *testing.T) { 48 for key, value := range test.set { 49 viper.Set(key, value) 50 viper.Set("customer-endpoint", "https://g.replicated.com") 51 } 52 53 req := require.New(t) 54 55 container, err := buildInjector(viper.GetViper()) 56 req.NoError(err) 57 58 err = container.Invoke(func(s *Ship) error { 59 // don't do anything with it, just make sure we can get one 60 return nil 61 }) 62 63 req.NoError(err) 64 65 }) 66 67 } 68 }