Skip to content

Commit

Permalink
Eradicating server service from fleetdb repo (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alva8756 committed Feb 22, 2024
1 parent cce197c commit d1ebd1b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/v1/router_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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))

Expand Down Expand Up @@ -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 {
Expand Down
44 changes: 22 additions & 22 deletions pkg/api/v1/server_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}`))
Expand All @@ -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)
Expand All @@ -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})
Expand All @@ -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})
Expand All @@ -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)
Expand All @@ -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"}`))
Expand All @@ -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})
Expand All @@ -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)
Expand All @@ -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})
Expand All @@ -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)
Expand All @@ -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})
Expand All @@ -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})
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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"}`))
Expand All @@ -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})
Expand All @@ -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})
Expand All @@ -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(),
Expand All @@ -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)
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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)
Expand Down

0 comments on commit d1ebd1b

Please sign in to comment.