github.com/OctopusDeploy/go-octopusdeploy@v1.8.6/octopusdeploy/root_service_test.go (about) 1 package octopusdeploy 2 3 import ( 4 "testing" 5 6 "github.com/dghubble/sling" 7 "github.com/stretchr/testify/require" 8 ) 9 10 func createRootService(t *testing.T) *rootService { 11 service := newRootService(nil, TestURIRoot) 12 testNewService(t, service, TestURIRoot, ServiceRootService) 13 return service 14 } 15 16 func BenchmarkRootServiceGet(b *testing.B) { 17 newRootService(nil, TestURIRoot).Get() 18 } 19 20 func TestRootServiceGet(t *testing.T) { 21 service := createRootService(t) 22 require.NotNil(t, service) 23 24 resource, err := service.Get() 25 require.NoError(t, err) 26 require.NotNil(t, resource) 27 } 28 29 func TestRootServiceNew(t *testing.T) { 30 ServiceFunction := newRootService 31 client := &sling.Sling{} 32 uriTemplate := emptyString 33 ServiceName := ServiceRootService 34 35 testCases := []struct { 36 name string 37 f func(*sling.Sling, string) *rootService 38 client *sling.Sling 39 uriTemplate string 40 }{ 41 {"NilClient", ServiceFunction, nil, uriTemplate}, 42 {"EmptyURITemplate", ServiceFunction, client, emptyString}, 43 {"URITemplateWithWhitespace", ServiceFunction, client, whitespaceString}, 44 } 45 for _, tc := range testCases { 46 t.Run(tc.name, func(t *testing.T) { 47 service := tc.f(tc.client, tc.uriTemplate) 48 testNewService(t, service, uriTemplate, ServiceName) 49 }) 50 } 51 }