Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and refactor TestAccountBetaPrograms #411

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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