Skip to content

Commit

Permalink
Fix and refactor TestAccountBetaPrograms (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai authored Oct 20, 2023
1 parent 66e79a8 commit f36e2e3
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 250 deletions.
47 changes: 21 additions & 26 deletions test/integration/account_betas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,39 @@ import (
"github.com/linode/linodego"
)

func TestAccountBetaPrograms_List(t *testing.T) {
client, teardown := createTestClient(t, "fixtures/TestAccountBetaPrograms_List")
func TestAccountBetaPrograms(t *testing.T) {
client, teardown := createTestClient(t, "fixtures/TestAccountBetaPrograms")
defer teardown()

betas, err := client.ListAccountBetaPrograms(context.Background(), &linodego.ListOptions{})
if err != nil {
t.Errorf("Error getting Account Beta programs, expected struct, got error %v", err)
}
betas, err := client.ListBetaPrograms(context.Background(), linodego.NewListOptions(1, ""))

if len(betas) == 0 {
t.Errorf("Expected to see account beta program returned.")
} else {
assertDateSet(t, betas[0].Enrolled)
t.Log("No beta program is available during the test.")
return
}
}

func TestAccountBetaProgram_Get(t *testing.T) {
client, teardown := createTestClient(t, "fixtures/TestAccountBetaProgram_Get")
defer teardown()
createOpts := linodego.AccountBetaProgramCreateOpts{ID: betas[0].ID}

betaID := "cool-beta"

// Enroll the account into a beta program.
createOpts := linodego.AccountBetaProgramCreateOpts{ID: betaID}

_, err := client.JoinBetaProgram(context.Background(), createOpts)
_, err = client.JoinBetaProgram(context.Background(), createOpts)
if err != nil {
t.Errorf("Error joining a Beta program, expected struct, got error %v", err)
}

beta, err := client.GetAccountBetaProgram(context.Background(), betaID)

accountBetas, err := client.ListAccountBetaPrograms(context.Background(), &linodego.ListOptions{})
if err != nil {
t.Errorf("Error getting an Account Beta program, expected struct, got error %v", err)
t.Errorf("Error getting Account Beta programs, expected struct, got error %v", err)
}

if beta.ID != betaID {
t.Errorf("expected beta ID to be %s; got %s", betaID, beta.ID)
if len(accountBetas) == 0 {
t.Errorf("Expected to see account beta program returned.")
} else {
assertDateSet(t, accountBetas[0].Enrolled)
betaID := accountBetas[0].ID
beta, err := client.GetAccountBetaProgram(context.Background(), betaID)
if err != nil {
t.Errorf("Error getting an Account Beta program, expected struct, got error %v", err)
}
if beta.ID != betaID {
t.Errorf("expected beta ID to be %s; got %s", betaID, beta.ID)
}
}

}
139 changes: 0 additions & 139 deletions test/integration/fixtures/TestAccountBetaProgram_Get.yaml

This file was deleted.

Loading

0 comments on commit f36e2e3

Please sign in to comment.