Skip to content

Commit

Permalink
feat: use dto in getfeatures
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdmike committed Jul 9, 2024
1 parent 8f6ecc2 commit 2d3bc4f
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 602 deletions.
11 changes: 10 additions & 1 deletion internal/controller/http/v1/devicemanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,16 @@ func (r *deviceManagementRoutes) getFeatures(c *gin.Context) {
return
}

c.JSON(http.StatusOK, features)
v1Features := map[string]interface{}{
"redirection": features.Redirection,
"KVM": features.EnableKVM,
"SOL": features.EnableSOL,
"IDER": features.EnableIDER,
"optInState": features.OptInState,
"userConsent": features.UserConsent,
}

c.JSON(http.StatusOK, v1Features)
}

func (r *deviceManagementRoutes) setFeatures(c *gin.Context) {
Expand Down
24 changes: 12 additions & 12 deletions internal/controller/http/v1/devicemanagement_mocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/controller/http/v1/devicemanagement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func deviceManagementTest(t *testing.T) (*MockDeviceManagementFeature, *gin.Engi

var aGoodTime = time.Unix(int64(1073007983), 0)

func TestGetNetworkSettings(t *testing.T) {
func TestDeviceManagement(t *testing.T) {
t.Parallel()

tests := []struct {
Expand Down Expand Up @@ -69,10 +69,10 @@ func TestGetNetworkSettings(t *testing.T) {
method: http.MethodGet,
mock: func(m *MockDeviceManagementFeature) {
m.EXPECT().GetFeatures(context.Background(), "valid-guid").
Return(map[string]interface{}{"features": []string{"feature1", "feature2"}}, nil)
Return(dto.Features{}, nil)
},
expectedCode: http.StatusOK,
response: map[string]interface{}{"features": []string{"feature1", "feature2"}},
response: map[string]interface{}{"IDER": false, "KVM": false, "SOL": false, "redirection": false, "optInState": 0, "userConsent": ""},
},
{
name: "setFeatures - successful setting",
Expand Down
Loading

0 comments on commit 2d3bc4f

Please sign in to comment.