Skip to content

Commit

Permalink
images: use testAccountID in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpi committed Jan 10, 2022
1 parent 9f46ad2 commit a19385e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var expectedImageStruct = Image{
}

func TestUploadImage(t *testing.T) {
setup(UsingAccount("foo"))
setup(UsingAccount(testAccountID))
defer teardown()

handler := func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestUploadImage(t *testing.T) {
`)
}

mux.HandleFunc("/accounts/foo/images/v1", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/images/v1", handler)
want := expectedImageStruct

actual, err := client.UploadImage(context.Background(), client.AccountID, ImageUploadRequest{
Expand All @@ -97,7 +97,7 @@ func TestUploadImage(t *testing.T) {
}

func TestUpdateImage(t *testing.T) {
setup(UsingAccount("foo"))
setup(UsingAccount(testAccountID))
defer teardown()

input := ImageUpdateRequest{
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestUpdateImage(t *testing.T) {
`)
}

mux.HandleFunc("/accounts/foo/images/v1/ZxR0pLaXRldlBtaFhhO2FiZGVnaA", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/images/v1/ZxR0pLaXRldlBtaFhhO2FiZGVnaA", handler)
want := expectedImageStruct

actual, err := client.UpdateImage(context.Background(), client.AccountID, "ZxR0pLaXRldlBtaFhhO2FiZGVnaA", input)
Expand All @@ -149,7 +149,7 @@ func TestUpdateImage(t *testing.T) {
}

func TestCreateImageDirectUploadURL(t *testing.T) {
setup(UsingAccount("foo"))
setup(UsingAccount(testAccountID))
defer teardown()

input := ImageDirectUploadURLRequest{
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestCreateImageDirectUploadURL(t *testing.T) {
`)
}

mux.HandleFunc("/accounts/foo/images/v1/direct_upload", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/images/v1/direct_upload", handler)
want := ImageDirectUploadURL{
ID: "ZxR0pLaXRldlBtaFhhO2FiZGVnaA",
UploadURL: "https://upload.imagedelivery.net/fgr33htrthytjtyereifjewoi338272s7w1383",
Expand All @@ -191,7 +191,7 @@ func TestCreateImageDirectUploadURL(t *testing.T) {
}

func TestListImages(t *testing.T) {
setup(UsingAccount("foo"))
setup(UsingAccount(testAccountID))
defer teardown()

handler := func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestListImages(t *testing.T) {
`)
}

mux.HandleFunc("/accounts/foo/images/v1", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/images/v1", handler)
want := []Image{expectedImageStruct}

actual, err := client.ListImages(context.Background(), client.AccountID, PaginationOptions{})
Expand All @@ -234,7 +234,7 @@ func TestListImages(t *testing.T) {
}

func TestImageDetails(t *testing.T) {
setup(UsingAccount("foo"))
setup(UsingAccount(testAccountID))
defer teardown()

handler := func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -262,7 +262,7 @@ func TestImageDetails(t *testing.T) {
`)
}

mux.HandleFunc("/accounts/foo/images/v1/ZxR0pLaXRldlBtaFhhO2FiZGVnaA", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/images/v1/ZxR0pLaXRldlBtaFhhO2FiZGVnaA", handler)
want := expectedImageStruct

actual, err := client.ImageDetails(context.Background(), client.AccountID, "ZxR0pLaXRldlBtaFhhO2FiZGVnaA")
Expand All @@ -273,7 +273,7 @@ func TestImageDetails(t *testing.T) {
}

func TestBaseImage(t *testing.T) {
setup(UsingAccount("foo"))
setup(UsingAccount(testAccountID))
defer teardown()

handler := func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -282,7 +282,7 @@ func TestBaseImage(t *testing.T) {
_, _ = w.Write([]byte{})
}

mux.HandleFunc("/accounts/foo/images/v1/ZxR0pLaXRldlBtaFhhO2FiZGVnaA/blob", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/images/v1/ZxR0pLaXRldlBtaFhhO2FiZGVnaA/blob", handler)
want := []byte{}

actual, err := client.BaseImage(context.Background(), client.AccountID, "ZxR0pLaXRldlBtaFhhO2FiZGVnaA")
Expand All @@ -293,7 +293,7 @@ func TestBaseImage(t *testing.T) {
}

func TestDeleteImage(t *testing.T) {
setup(UsingAccount("foo"))
setup(UsingAccount(testAccountID))
defer teardown()

handler := func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -308,7 +308,7 @@ func TestDeleteImage(t *testing.T) {
`)
}

mux.HandleFunc("/accounts/foo/images/v1/ZxR0pLaXRldlBtaFhhO2FiZGVnaA", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/images/v1/ZxR0pLaXRldlBtaFhhO2FiZGVnaA", handler)

err := client.DeleteImage(context.Background(), client.AccountID, "ZxR0pLaXRldlBtaFhhO2FiZGVnaA")
require.NoError(t, err)
Expand Down

0 comments on commit a19385e

Please sign in to comment.