forked from OpsLevel/opslevel-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliases_test.go
58 lines (48 loc) · 1.91 KB
/
aliases_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package opslevel_test
import (
"testing"
"github.com/rocktavious/autopilot/v2023"
)
func TestCreateAliases(t *testing.T) {
// Arrange
testRequest := NewTestRequest(
`"mutation AliasCreate($input:AliasCreateInput!){aliasCreate(input: $input){aliases,ownerId,errors{message,path}}}"`,
`{"input": { "alias": "MyAwesomeAlias", "ownerId": "Z2lkOi8vb3BzbGV2ZWwvU2VydmljZS80MTc2" }}`,
`{"data": { "aliasCreate": { "aliases": [ "MyCoolService", "MyAwesomeAlias" ], "ownerId": "Z2lkOi8vb3BzbGV2ZWwvU2VydmljZS80MTc2", "errors": [] }}}`,
)
client := BestTestClient(t, "aliases/create", testRequest)
// Act
result, err := client.CreateAliases("Z2lkOi8vb3BzbGV2ZWwvU2VydmljZS80MTc2", []string{"MyAwesomeAlias"})
// Assert
autopilot.Ok(t, err)
autopilot.Equals(t, 2, len(result))
autopilot.Equals(t, "MyAwesomeAlias", result[1])
}
// TODO: Add CreateAliasesOwnerNotFound
func TestDeleteServiceAlias(t *testing.T) {
// Arrange
testRequest := NewTestRequest(
`"mutation AliasDelete($input:AliasDeleteInput!){aliasDelete(input: $input){deletedAlias,errors{message,path}}}"`,
`{"input": { "alias": "MyAwesomeAlias", "ownerType": "service" }}`,
`{"data": { "aliasDelete": { "deletedAlias": "MyAwesomeAlias", "errors": [] }}}`,
)
client := BestTestClient(t, "aliases/delete_service", testRequest)
// Act
err := client.DeleteServiceAlias("MyAwesomeAlias")
// Assert
autopilot.Ok(t, err)
}
func TestDeleteTeamAlias(t *testing.T) {
// Arrange
testRequest := NewTestRequest(
`"mutation AliasDelete($input:AliasDeleteInput!){aliasDelete(input: $input){deletedAlias,errors{message,path}}}"`,
`{"input": { "alias": "MyAwesomeAlias", "ownerType": "team" }}`,
`{"data": { "aliasDelete": { "deletedAlias": "MyAwesomeAlias", "errors": [] }}}`,
)
client := BestTestClient(t, "aliases/delete_team", testRequest)
// Act
err := client.DeleteTeamAlias("MyAwesomeAlias")
// Assert
autopilot.Ok(t, err)
}
// TODO: Add DeleteAliasNotFound