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

tests: add patch, put, int64, cap.letter tests #4636

Merged
merged 11 commits into from Aug 18, 2021
47 changes: 25 additions & 22 deletions compute/apiv1/smoke_test.go
Expand Up @@ -19,7 +19,7 @@ package compute
import (
"context"
"fmt"
"reflect"
"github.com/google/go-cmp/cmp"
"testing"

"cloud.google.com/go/internal/testutil"
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestCreateGetPutPatchListInstance(t *testing.T) {
if get.GetDescription() != "тест" {
t.Fatal(fmt.Sprintf("expected instance description: %s, got: %s", "тест", get.GetDescription()))
}
if get.GetShieldedInstanceConfig().GetEnableSecureBoot() != false {
if secureBootEnabled := get.GetShieldedInstanceConfig().GetEnableSecureBoot(); secureBootEnabled {
t.Fatal(fmt.Sprintf("expected instance secure boot: %t, got: %t", false, get.GetShieldedInstanceConfig().GetEnableSecureBoot()))
noahdietz marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -157,10 +157,10 @@ func TestCreateGetPutPatchListInstance(t *testing.T) {
t.Error(err)
}
if fetched.GetDescription() != "updated" {
t.Fatal(fmt.Sprintf("expected instance description: %s, got: %s", "updated", get.GetDescription()))
t.Fatal(fmt.Sprintf("expected instance description: %s, got: %s", "updated", fetched.GetDescription()))
noahdietz marked this conversation as resolved.
Show resolved Hide resolved
}
if fetched.GetShieldedInstanceConfig().GetEnableSecureBoot() != true {
t.Fatal(fmt.Sprintf("expected instance secure boot: %t, got: %t", true, get.GetShieldedInstanceConfig().GetEnableSecureBoot()))
if secureBootEnabled := fetched.GetShieldedInstanceConfig().GetEnableSecureBoot(); !secureBootEnabled {
t.Fatal(fmt.Sprintf("expected instance secure boot: %t, got: %t", true, secureBootEnabled))
noahdietz marked this conversation as resolved.
Show resolved Hide resolved
}
listRequest := &computepb.ListInstancesRequest{
Project: projectId,
Expand Down Expand Up @@ -492,23 +492,24 @@ func TestTypeInt64(t *testing.T) {
if err != nil {
t.Error(err)
}

defer func(c *ImagesClient, ctx context.Context, req *computepb.DeleteImageRequest) {
_, err := c.Delete(ctx, req)
if err != nil {
}
}(c, ctx, &computepb.DeleteImageRequest{
delReq := &computepb.DeleteImageRequest{
noahdietz marked this conversation as resolved.
Show resolved Hide resolved
Project: projectId,
Image: name,
})
}
defer func() {
_, err := c.Delete(ctx, delReq)
if err != nil {
t.Error(err)
}
}()

fetched, err := c.Get(ctx,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the error here after this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

&computepb.GetImageRequest{
Project: projectId,
Image: name,
})
if !reflect.DeepEqual(fetched.GetLicenseCodes(), codes) {
t.Fatal("License codes are not equal")
if diff := cmp.Diff(fetched.GetLicenseCodes(), codes, cmp.Comparer(proto.Equal)); diff != "" {
t.Fatalf("got(-),want(+):\n%s", diff)
}
}

Expand Down Expand Up @@ -558,19 +559,21 @@ func TestCapitalLetter(t *testing.T) {
if err != nil {
t.Error(err)
}
defer func(c *FirewallsClient, ctx context.Context, req *computepb.DeleteFirewallRequest) {
_, err := c.Delete(ctx, req)
if err != nil {
}
}(c, ctx, &computepb.DeleteFirewallRequest{
delReq := &computepb.DeleteFirewallRequest{
noahdietz marked this conversation as resolved.
Show resolved Hide resolved
Project: projectId,
Firewall: name,
})
}
defer func() {
_, err := c.Delete(ctx, delReq)
if err != nil {
t.Error(err)
}
}()
fetched, err := c.Get(ctx, &computepb.GetFirewallRequest{
noahdietz marked this conversation as resolved.
Show resolved Hide resolved
Project: projectId,
Firewall: name,
})
if !reflect.DeepEqual(fetched.GetAllowed(), allowed) {
t.Fatal("Firewall contains unexpected values.")
if diff := cmp.Diff(fetched.GetAllowed(), allowed, cmp.Comparer(proto.Equal)); diff != "" {
t.Fatalf("got(-),want(+):\n%s", diff)
}
}