diff --git a/Makefile b/Makefile index 2690772..d5a2ebe 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ integration-test: test-database ## run lint and unit tests unit-test: | lint @echo Running unit tests... - @SERVERSERVICE_CRDB_URI="${TEST_DB}" go test -cover -short -tags testtools ./... + @FLEETDB_CRDB_URI="${TEST_DB}" go test -cover -short -tags testtools ./... ## check test coverage coverage: | test-database diff --git a/cmd/root.go b/cmd/root.go index 1f21dca..3f229f0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -25,7 +25,7 @@ var ( // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "serverservice", + Use: "fleetdb", Short: "Server Service for Hollow ecosystem", } diff --git a/cmd/serve.go b/cmd/serve.go index 2bd27a8..1749bde 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -69,10 +69,10 @@ func init() { rootCmd.PersistentFlags().String("nats-stream-name", appName, "prefix for NATS subjects") viperx.MustBindFlag(viper.GetViper(), "nats.stream.name", rootCmd.PersistentFlags().Lookup("nats-stream-name")) - rootCmd.PersistentFlags().String("nats-stream-prefix", "com.hollow.sh.serverservice.events", "NATS stream prefix") + rootCmd.PersistentFlags().String("nats-stream-prefix", "com.hollow.sh.fleetdb.events", "NATS stream prefix") viperx.MustBindFlag(viper.GetViper(), "nats.stream.prefix", rootCmd.PersistentFlags().Lookup("nats-stream-prefix")) - rootCmd.PersistentFlags().StringSlice("nats-stream-subjects", []string{"com.hollow.sh.serverservice.events.>"}, "NATS stream subject(s)") + rootCmd.PersistentFlags().StringSlice("nats-stream-subjects", []string{"com.hollow.sh.fleetdb.events.>"}, "NATS stream subject(s)") viperx.MustBindFlag(viper.GetViper(), "nats.stream.subjects", rootCmd.PersistentFlags().Lookup("nats-stream-subjects")) rootCmd.PersistentFlags().String("nats-stream-urn-ns", "hollow", "NATS stream URN namespace value") diff --git a/pkg/api/v1/router_server_test.go b/pkg/api/v1/router_server_test.go index 3ffcdd6..94793f1 100644 --- a/pkg/api/v1/router_server_test.go +++ b/pkg/api/v1/router_server_test.go @@ -712,7 +712,7 @@ func TestIntegrationServerUpdate(t *testing.T) { }) } -func TestIntegrationServerServiceCreateVersionedAttributes(t *testing.T) { +func TestIntegrationFleetdbCreateVersionedAttributes(t *testing.T) { s := serverTest(t) realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { @@ -729,7 +729,7 @@ func TestIntegrationServerServiceCreateVersionedAttributes(t *testing.T) { }) } -func TestIntegrationServerServiceCreateVersionedAttributesIncrementCounter(t *testing.T) { +func TestIntegrationFleetdbCreateVersionedAttributesIncrementCounter(t *testing.T) { s := serverTest(t) s.Client.SetToken(validToken(adminScopes)) @@ -769,7 +769,7 @@ func TestIntegrationServerServiceCreateVersionedAttributesIncrementCounter(t *te assert.Equal(t, 1, r[1].Tally) } -func TestIntegrationServerServiceListVersionedAttributes(t *testing.T) { +func TestIntegrationFleetdbListVersionedAttributes(t *testing.T) { s := serverTest(t) realClientTests(t, func(ctx context.Context, authToken string, respCode int, expectError bool) error { diff --git a/pkg/api/v1/server_service_test.go b/pkg/api/v1/server_service_test.go index 89d19f3..da8f4f8 100644 --- a/pkg/api/v1/server_service_test.go +++ b/pkg/api/v1/server_service_test.go @@ -12,7 +12,7 @@ import ( fleetdbapi "github.com/metal-toolbox/fleetdb/pkg/api/v1" ) -func TestServerServiceCreate(t *testing.T) { +func TestFleetdbCreate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { srv := fleetdbapi.Server{UUID: uuid.New(), FacilityCode: "Test1"} jsonResponse := json.RawMessage([]byte(`{"message": "resource created", "slug":"00000000-0000-0000-0000-000000001234"}`)) @@ -27,7 +27,7 @@ func TestServerServiceCreate(t *testing.T) { }) } -func TestServerServiceDelete(t *testing.T) { +func TestFleetdbDelete(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse := json.RawMessage([]byte(`{"message": "resource deleted"}`)) c := mockClient(string(jsonResponse), respCode) @@ -36,7 +36,7 @@ func TestServerServiceDelete(t *testing.T) { return err }) } -func TestServerServiceGet(t *testing.T) { +func TestFleetdbGet(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { srv := fleetdbapi.Server{UUID: uuid.New(), FacilityCode: "Test1"} jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Record: srv}) @@ -53,7 +53,7 @@ func TestServerServiceGet(t *testing.T) { }) } -func TestServerServiceList(t *testing.T) { +func TestFleetdbList(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { srv := []fleetdbapi.Server{{UUID: uuid.New(), FacilityCode: "Test1"}} jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Records: srv}) @@ -69,7 +69,7 @@ func TestServerServiceList(t *testing.T) { }) } -func TestServerServiceUpdate(t *testing.T) { +func TestFleetdbUpdate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Message: "resource updated"}) require.Nil(t, err) @@ -81,7 +81,7 @@ func TestServerServiceUpdate(t *testing.T) { }) } -func TestServerServiceCreateAttributes(t *testing.T) { +func TestFleetdbCreateAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { attr := fleetdbapi.Attributes{Namespace: "unit-test", Data: json.RawMessage([]byte(`{"test":"unit"}`))} jsonResponse := json.RawMessage([]byte(`{"message": "resource created"}`)) @@ -92,7 +92,7 @@ func TestServerServiceCreateAttributes(t *testing.T) { return err }) } -func TestServerServiceGetAttributes(t *testing.T) { +func TestFleetdbGetAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { attr := &fleetdbapi.Attributes{Namespace: "unit-test", Data: json.RawMessage([]byte(`{"test":"unit"}`))} jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Record: attr}) @@ -108,7 +108,7 @@ func TestServerServiceGetAttributes(t *testing.T) { }) } -func TestServerServiceDeleteAttributes(t *testing.T) { +func TestFleetdbDeleteAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Message: "resource deleted"}) require.Nil(t, err) @@ -120,7 +120,7 @@ func TestServerServiceDeleteAttributes(t *testing.T) { }) } -func TestServerServiceListAttributes(t *testing.T) { +func TestFleetdbListAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { attrs := []fleetdbapi.Attributes{{Namespace: "unit-test", Data: json.RawMessage([]byte(`{"test":"unit"}`))}} jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Records: attrs}) @@ -136,7 +136,7 @@ func TestServerServiceListAttributes(t *testing.T) { }) } -func TestServerServiceUpdateAttributes(t *testing.T) { +func TestFleetdbUpdateAttributes(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Message: "resource updated"}) require.Nil(t, err) @@ -148,7 +148,7 @@ func TestServerServiceUpdateAttributes(t *testing.T) { }) } -func TestServerServiceComponentsGet(t *testing.T) { +func TestFleetdbComponentsGet(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { sc := []fleetdbapi.ServerComponent{{Name: "unit-test", Serial: "1234"}} jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Records: sc}) @@ -164,7 +164,7 @@ func TestServerServiceComponentsGet(t *testing.T) { }) } -func TestServerServiceComponentsList(t *testing.T) { +func TestFleetdbComponentsList(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { sc := []fleetdbapi.ServerComponent{{Name: "unit-test", Serial: "1234"}} jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Records: sc}) @@ -180,7 +180,7 @@ func TestServerServiceComponentsList(t *testing.T) { }) } -func TestServerServiceComponentsCreate(t *testing.T) { +func TestFleetdbComponentsCreate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Message: "resource created"}) require.Nil(t, err) @@ -195,7 +195,7 @@ func TestServerServiceComponentsCreate(t *testing.T) { }) } -func TestServerServiceComponentsUpdate(t *testing.T) { +func TestFleetdbComponentsUpdate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Message: "resource updated"}) require.Nil(t, err) @@ -210,7 +210,7 @@ func TestServerServiceComponentsUpdate(t *testing.T) { }) } -func TestServerServiceVersionedAttributeCreate(t *testing.T) { +func TestFleetdbVersionedAttributeCreate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { va := fleetdbapi.VersionedAttributes{Namespace: "unit-test", Data: json.RawMessage([]byte(`{"test":"unit"}`))} jsonResponse := json.RawMessage([]byte(`{"message": "resource created", "slug":"the-namespace"}`)) @@ -225,7 +225,7 @@ func TestServerServiceVersionedAttributeCreate(t *testing.T) { }) } -func TestServerServiceGetVersionedAttributess(t *testing.T) { +func TestFleetdbGetVersionedAttributess(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { va := []fleetdbapi.VersionedAttributes{{Namespace: "test", Data: json.RawMessage([]byte(`{}`))}} jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Records: va}) @@ -241,7 +241,7 @@ func TestServerServiceGetVersionedAttributess(t *testing.T) { }) } -func TestServerServiceListVersionedAttributess(t *testing.T) { +func TestFleetdbListVersionedAttributess(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { va := []fleetdbapi.VersionedAttributes{{Namespace: "test", Data: json.RawMessage([]byte(`{}`))}} jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Records: va}) @@ -257,7 +257,7 @@ func TestServerServiceListVersionedAttributess(t *testing.T) { }) } -func TestServerServiceCreateServerComponentFirmware(t *testing.T) { +func TestFleetdbCreateServerComponentFirmware(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { firmware := fleetdbapi.ComponentFirmwareVersion{ UUID: uuid.New(), @@ -277,7 +277,7 @@ func TestServerServiceCreateServerComponentFirmware(t *testing.T) { }) } -func TestServerServiceServerComponentFirmwareDelete(t *testing.T) { +func TestFleetdbServerComponentFirmwareDelete(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse := json.RawMessage([]byte(`{"message": "resource deleted"}`)) c := mockClient(string(jsonResponse), respCode) @@ -286,7 +286,7 @@ func TestServerServiceServerComponentFirmwareDelete(t *testing.T) { return err }) } -func TestServerServiceServerComponentFirmwareGet(t *testing.T) { +func TestFleetdbServerComponentFirmwareGet(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { firmware := fleetdbapi.ComponentFirmwareVersion{ UUID: uuid.New(), @@ -310,7 +310,7 @@ func TestServerServiceServerComponentFirmwareGet(t *testing.T) { }) } -func TestServerServiceServerComponentFirmwareList(t *testing.T) { +func TestFleetdbServerComponentFirmwareList(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { firmware := []fleetdbapi.ComponentFirmwareVersion{{ UUID: uuid.New(), @@ -331,7 +331,7 @@ func TestServerServiceServerComponentFirmwareList(t *testing.T) { }) } -func TestServerServiceServerComponentFirmwareUpdate(t *testing.T) { +func TestFleetdbServerComponentFirmwareUpdate(t *testing.T) { mockClientTests(t, func(ctx context.Context, respCode int, expectError bool) error { jsonResponse, err := json.Marshal(fleetdbapi.ServerResponse{Message: "resource updated"}) require.Nil(t, err)