Skip to content

Commit 33f9c6d

Browse files
committed
update tests, some input structs, work remains in gen.go
1 parent e8c5eed commit 33f9c6d

15 files changed

+422
-325
lines changed

actions.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ func (client *Client) CreateTriggerDefinition(input CustomActionsTriggerDefiniti
228228
Errors []OpsLevelErrors
229229
} `graphql:"customActionsTriggerDefinitionCreate(input: $input)"`
230230
}
231-
if input.AccessControl == "" {
232-
input.AccessControl = CustomActionsTriggerDefinitionAccessControlEnumEveryone
231+
if input.AccessControl != nil {
232+
input.AccessControl = NewEnum[CustomActionsTriggerDefinitionAccessControlEnum](CustomActionsTriggerDefinitionAccessControlEnumEveryone)
233233
}
234-
if input.EntityType == "" {
235-
input.EntityType = CustomActionsEntityTypeEnumService
234+
if input.EntityType == nil {
235+
input.EntityType = NewEnum[CustomActionsEntityTypeEnum](CustomActionsEntityTypeEnumService)
236236
}
237237
v := PayloadVariables{
238238
"input": input,

actions_test.go

+35-28
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestCreateWebhookAction(t *testing.T) {
1313
// Arrange
1414
testRequest := autopilot.NewTestRequest(
1515
`mutation WebhookActionCreate($input:CustomActionsWebhookActionCreateInput!){customActionsWebhookActionCreate(input: $input){webhookAction{{ template "custom_actions_request" }},errors{message,path}}}`,
16-
`{"input":{"headers":"{\"Content-Type\":\"application/json\"}","httpMethod":"POST",{{ template "liquid_template_rollback" }},"name":"Deploy Rollback","webhookUrl":"https://gitlab.com/api/v4/projects/1/trigger/pipeline"}}`,
16+
`{"input":{"headers":["{\"Content-Type\":\"application/json\"}"],"httpMethod":"POST",{{ template "liquid_template_rollback" }},"name":"Deploy Rollback","webhookUrl":"https://gitlab.com/api/v4/projects/1/trigger/pipeline"}}`,
1717
`{"data": {"customActionsWebhookActionCreate": { "webhookAction": {{ template "custom_action1" }}, "errors": [] }}}`,
1818
)
1919

@@ -23,11 +23,9 @@ func TestCreateWebhookAction(t *testing.T) {
2323
action, err := client.CreateWebhookAction(ol.CustomActionsWebhookActionCreateInput{
2424
Name: "Deploy Rollback",
2525
LiquidTemplate: ol.NewString("{\"token\": \"XXX\", \"ref\":\"main\", \"action\": \"rollback\"}"),
26-
Headers: ol.JSON{
27-
"Content-Type": "application/json",
28-
},
29-
HTTPMethod: ol.CustomActionsHttpMethodEnumPost,
30-
WebhookURL: "https://gitlab.com/api/v4/projects/1/trigger/pipeline",
26+
Headers: &[]ol.JSON{{"Content-Type": "application/json"}},
27+
HttpMethod: ol.CustomActionsHttpMethodEnumPost,
28+
WebhookUrl: "https://gitlab.com/api/v4/projects/1/trigger/pipeline",
3129
})
3230

3331
// Assert
@@ -73,7 +71,7 @@ func TestUpdateWebhookAction(t *testing.T) {
7371
// Act
7472
action, err := client.UpdateWebhookAction(ol.CustomActionsWebhookActionUpdateInput{
7573
Id: *newID,
76-
HTTPMethod: ol.CustomActionsHttpMethodEnumPut,
74+
HttpMethod: ol.NewEnum[ol.CustomActionsHttpMethodEnum](ol.CustomActionsHttpMethodEnumPut),
7775
})
7876

7977
// Assert
@@ -85,7 +83,7 @@ func TestUpdateWebhookAction2(t *testing.T) {
8583
// Arrange
8684
testRequest := autopilot.NewTestRequest(
8785
`mutation WebhookActionUpdate($input:CustomActionsWebhookActionUpdateInput!){customActionsWebhookActionUpdate(input: $input){webhookAction{{ template "custom_actions_request" }},errors{message,path}}}`,
88-
`{"input":{"id": "123456789","description":"","headers":"{\"Accept\":\"application/json\"}"}}`,
86+
`{"input":{"id": "123456789","description":"","headers":["{\"Accept\":\"application/json\"}"]}}`,
8987
`{"data": {"customActionsWebhookActionUpdate": { "webhookAction": {{ template "custom_action1" }}, "errors": [] }}}`,
9088
)
9189

@@ -98,7 +96,7 @@ func TestUpdateWebhookAction2(t *testing.T) {
9896
action, err := client.UpdateWebhookAction(ol.CustomActionsWebhookActionUpdateInput{
9997
Id: *newID,
10098
Description: ol.NewString(""),
101-
Headers: &headers,
99+
Headers: &[]ol.JSON{headers},
102100
})
103101

104102
// Assert
@@ -134,11 +132,14 @@ func TestCreateTriggerDefinition(t *testing.T) {
134132

135133
// Act
136134
trigger, err := client.CreateTriggerDefinition(ol.CustomActionsTriggerDefinitionCreateInput{
137-
Name: "Deploy Rollback",
138-
Description: ol.NewString("Disables the Deploy Freeze"),
139-
Action: *newID,
140-
Owner: *newID,
141-
Filter: ol.NewID("987654321"),
135+
Name: "Deploy Rollback",
136+
AccessControl: ol.NewEnum[ol.CustomActionsTriggerDefinitionAccessControlEnum](ol.CustomActionsTriggerDefinitionAccessControlEnumEveryone),
137+
Description: ol.NewString("Disables the Deploy Freeze"),
138+
ResponseTemplate: ol.NewString(""),
139+
ManualInputsDefinition: ol.NewString(""),
140+
ActionId: newID,
141+
OwnerId: *newID,
142+
FilterId: ol.NewID("987654321"),
142143
})
143144
// Assert
144145
autopilot.Ok(t, err)
@@ -156,12 +157,15 @@ func TestCreateTriggerDefinitionWithGlobalEntityType(t *testing.T) {
156157

157158
// Act
158159
trigger, err := client.CreateTriggerDefinition(ol.CustomActionsTriggerDefinitionCreateInput{
159-
Name: "Deploy Rollback",
160-
Description: ol.NewString("Disables the Deploy Freeze"),
161-
Action: *newID,
162-
Owner: *newID,
163-
Filter: ol.NewID("987654321"),
164-
EntityType: "GLOBAL",
160+
Name: "Deploy Rollback",
161+
AccessControl: ol.NewEnum[ol.CustomActionsTriggerDefinitionAccessControlEnum](ol.CustomActionsTriggerDefinitionAccessControlEnumEveryone),
162+
Description: ol.NewString("Disables the Deploy Freeze"),
163+
ActionId: newID,
164+
ManualInputsDefinition: ol.NewString(""),
165+
ResponseTemplate: ol.NewString(""),
166+
OwnerId: *newID,
167+
FilterId: ol.NewID("987654321"),
168+
EntityType: ol.NewEnum[ol.CustomActionsEntityTypeEnum](ol.CustomActionsEntityTypeEnumGlobal),
165169
ExtendedTeamAccess: &[]ol.IdentifierInput{
166170
*ol.NewIdentifier("example_1"),
167171
*ol.NewIdentifier("example_1"),
@@ -183,12 +187,15 @@ func TestCreateTriggerDefinitionWithNullExtendedTeams(t *testing.T) {
183187
client := BestTestClient(t, "custom_actions/create_trigger_with_null_extended_teams", testRequest)
184188
// Act
185189
trigger, err := client.CreateTriggerDefinition(ol.CustomActionsTriggerDefinitionCreateInput{
186-
Name: "Deploy Rollback",
187-
Description: ol.NewString("Disables the Deploy Freeze"),
188-
Action: *newID,
189-
Owner: *newID,
190-
Filter: ol.NewID("987654321"),
191-
ExtendedTeamAccess: &[]ol.IdentifierInput{},
190+
Name: "Deploy Rollback",
191+
Description: ol.NewString("Disables the Deploy Freeze"),
192+
AccessControl: ol.NewEnum[ol.CustomActionsTriggerDefinitionAccessControlEnum](ol.CustomActionsTriggerDefinitionAccessControlEnumEveryone),
193+
ManualInputsDefinition: ol.NewString(""),
194+
ResponseTemplate: ol.NewString(""),
195+
ActionId: newID,
196+
OwnerId: *newID,
197+
FilterId: ol.NewID("987654321"),
198+
ExtendedTeamAccess: &[]ol.IdentifierInput{},
192199
})
193200
// Assert
194201
autopilot.Ok(t, err)
@@ -253,8 +260,8 @@ func TestUpdateTriggerDefinition(t *testing.T) {
253260

254261
// Act
255262
trigger, err := client.UpdateTriggerDefinition(ol.CustomActionsTriggerDefinitionUpdateInput{
256-
Id: *newID,
257-
Filter: ol.NewID(),
263+
Id: *newID,
264+
FilterId: ol.NewID(),
258265
})
259266
// Assert
260267
autopilot.Ok(t, err)

check_manual.go

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ func NewManualCheckFrequencyInput(startingDate string, timeScale FrequencyTimeSc
2727
}
2828
}
2929

30+
func NewManualCheckFrequencyUpdateInput(startingDate string, timeScale FrequencyTimeScale, value int) *ManualCheckFrequencyUpdateInput {
31+
startingDateIso := NewISO8601Date(startingDate)
32+
return &ManualCheckFrequencyUpdateInput{
33+
StartingDate: &startingDateIso,
34+
FrequencyTimeScale: &timeScale,
35+
FrequencyValue: &value,
36+
}
37+
}
38+
3039
// type CheckManualCreateInput struct {
3140
// CheckCreateInput
3241

0 commit comments

Comments
 (0)