|
| 1 | +package e2e |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/scaleway/scaleway-sdk-go/api/test/v1" |
| 7 | + "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" |
| 8 | + "github.com/scaleway/scaleway-sdk-go/scw" |
| 9 | +) |
| 10 | + |
| 11 | +func TestStandardErrors(t *testing.T) { |
| 12 | + client, _, err := newE2EClient(true) |
| 13 | + testhelpers.AssertNoError(t, err) |
| 14 | + |
| 15 | + _, err = client.GetHuman(&test.GetHumanRequest{ |
| 16 | + HumanID: "b3ba839a-dcf2-4b0a-ac81-fc32370052a0", |
| 17 | + }) |
| 18 | + testhelpers.Equals(t, &scw.ResourceNotFound{ |
| 19 | + Resource: "human", |
| 20 | + ResourceID: "b3ba839a-dcf2-4b0a-ac81-fc32370052a0", |
| 21 | + }, err) |
| 22 | + |
| 23 | + _, err = client.CreateHuman(&test.CreateHumanRequest{ |
| 24 | + AltitudeInMeter: -7000000, |
| 25 | + }) |
| 26 | + testhelpers.Equals(t, &scw.InvalidArgumentsError{ |
| 27 | + Details: []struct { |
| 28 | + ArgumentName string `json:"argument_name"` |
| 29 | + Reason string `json:"reason"` |
| 30 | + HelpMessage string `json:"help_message"` |
| 31 | + }{ |
| 32 | + { |
| 33 | + ArgumentName: "altitude_in_meter", |
| 34 | + Reason: "constraint", |
| 35 | + HelpMessage: "lowest altitude on earth is -6371km", |
| 36 | + }, |
| 37 | + }, |
| 38 | + }, err) |
| 39 | + |
| 40 | + var human *test.Human |
| 41 | + for i := 0; i < 10; i++ { |
| 42 | + human, err = client.CreateHuman(&test.CreateHumanRequest{}) |
| 43 | + testhelpers.AssertNoError(t, err) |
| 44 | + } |
| 45 | + |
| 46 | + _, err = client.CreateHuman(&test.CreateHumanRequest{}) |
| 47 | + testhelpers.Equals(t, &scw.QuotasExceededError{ |
| 48 | + Details: []struct { |
| 49 | + Resource string `json:"resource"` |
| 50 | + Quota uint32 `json:"quota"` |
| 51 | + Current uint32 `json:"current"` |
| 52 | + }{ |
| 53 | + { |
| 54 | + Resource: "human", |
| 55 | + Quota: 10, |
| 56 | + Current: 10, |
| 57 | + }, |
| 58 | + }, |
| 59 | + }, err) |
| 60 | + |
| 61 | + _, err = client.RunHuman(&test.RunHumanRequest{HumanID: human.ID}) |
| 62 | + testhelpers.AssertNoError(t, err) |
| 63 | + |
| 64 | + _, err = client.UpdateHuman(&test.UpdateHumanRequest{HumanID: human.ID}) |
| 65 | + testhelpers.Equals(t, &scw.TransientStateError{ |
| 66 | + Resource: "human", |
| 67 | + ResourceID: human.ID, |
| 68 | + CurrentState: "running", |
| 69 | + }, err) |
| 70 | + |
| 71 | +} |
0 commit comments