-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests Suppress case difference
- Loading branch information
Showing
24 changed files
with
1,622 additions
and
730 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
inpackage: False | ||
with-expecter: True | ||
keeptree: False | ||
filename: "{{.InterfaceName | snakecase | lower }}_mock_test.go" | ||
mockname: "mock{{.InterfaceName}}" | ||
filename: "{{.InterfaceName | snakecase | lower }}_mock.go" | ||
mockname: "Mock{{.InterfaceName}}" | ||
|
||
packages: | ||
github.com/severalnines/terraform-provider-ccx/internal/ccx: | ||
interfaces: | ||
DatastoreService: | ||
config: | ||
dir: "./internal/ccx/api" | ||
outpkg: "api" | ||
github.com/severalnines/terraform-provider-ccx/internal/ccx/api: | ||
config: | ||
inpackage: True | ||
interfaces: | ||
jobService: | ||
dir: "./internal/ccx/mocks" | ||
outpkg: "mocks" | ||
ContentService: | ||
config: | ||
dir: "./internal/ccx/api" | ||
HttpClient: | ||
dir: "./internal/ccx/mocks" | ||
outpkg: "mocks" | ||
VPCService: | ||
config: | ||
dir: "./internal/ccx/api" | ||
outpkg: "api" | ||
dir: "./internal/ccx/mocks" | ||
outpkg: "mocks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package api | ||
|
||
type ContentService struct { | ||
client HttpClient | ||
} | ||
|
||
func Content(client HttpClient) (*ContentService, error) { | ||
c := ContentService{ | ||
client: client, | ||
} | ||
|
||
return &c, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/severalnines/terraform-provider-ccx/internal/ccx" | ||
) | ||
|
||
type deployWizardResponse struct { | ||
Instance struct { | ||
InstanceSizes map[string][]ccx.InstanceSize `json:"instance_sizes"` | ||
} `json:"instance"` | ||
} | ||
|
||
func (svc *ContentService) InstanceSizes(ctx context.Context) (map[string][]ccx.InstanceSize, error) { | ||
var rs deployWizardResponse | ||
|
||
err := svc.client.Get(ctx, "/api/content/api/v1/deploy-wizard", &rs) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return rs.Instance.InstanceSizes, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/severalnines/terraform-provider-ccx/internal/ccx" | ||
"github.com/severalnines/terraform-provider-ccx/internal/lib" | ||
) | ||
|
||
func (svc *DatastoreService) SetMaintenanceSettings(ctx context.Context, storeID string, settings ccx.MaintenanceSettings) error { | ||
ur := updateRequest{ | ||
Maintenance: &maintenance{ | ||
DayOfWeek: uint32(settings.DayOfWeek), | ||
StartHour: uint64(settings.StartHour), | ||
EndHour: uint64(settings.EndHour), | ||
}, | ||
} | ||
|
||
res, err := svc.client.Do(ctx, http.MethodPatch, "/api/prov/api/v2/cluster/"+storeID, ur) | ||
if err != nil { | ||
return errors.Join(ccx.RequestSendingErr, err) | ||
} | ||
|
||
if res.StatusCode == http.StatusBadRequest { | ||
return lib.ErrorFromErrorResponse(res.Body) | ||
} | ||
|
||
if res.StatusCode != http.StatusOK { | ||
return fmt.Errorf("%w: status = %d", ccx.ResponseStatusFailedErr, res.StatusCode) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.