Skip to content

Commit

Permalink
fix(storage): migrate deprecated proto dep (#9232)
Browse files Browse the repository at this point in the history
Migrates test usage of protobuf-go v1 lib to protobuf-go v2 lib.

Also migrates deprecated `ioutil` APIs to equivalent `os` APIs.

Fixes #9189
  • Loading branch information
noahdietz committed Jan 8, 2024
1 parent 9a79290 commit ebbb610
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions storage/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
package storage

import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"os"
"strconv"
"strings"
"testing"
"time"

storage_v1_tests "cloud.google.com/go/storage/internal/test/conformance"
"github.com/golang/protobuf/jsonpb"
"github.com/google/go-cmp/cmp"
"google.golang.org/protobuf/encoding/protojson"
)

func TestPostPolicyV4Conformance(t *testing.T) {
Expand Down Expand Up @@ -223,7 +223,7 @@ func parseFiles(t *testing.T) (googleAccessID, privateKey string, testFiles []*s
googleAccessID = serviceAccount["client_email"]
privateKey = serviceAccount["private_key"]

files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
t.Fatal(err)
}
Expand All @@ -233,13 +233,13 @@ func parseFiles(t *testing.T) (googleAccessID, privateKey string, testFiles []*s
continue
}

inBytes, err := ioutil.ReadFile(dir + "/" + f.Name())
inBytes, err := os.ReadFile(dir + "/" + f.Name())
if err != nil {
t.Fatalf("%s: %v", f.Name(), err)
}

testFile := new(storage_v1_tests.TestFile)
if err := jsonpb.Unmarshal(bytes.NewReader(inBytes), testFile); err != nil {
if err := protojson.Unmarshal(inBytes, testFile); err != nil {
t.Fatalf("unmarshalling %s: %v", f.Name(), err)
}
testFiles = append(testFiles, testFile)
Expand Down
2 changes: 1 addition & 1 deletion storage/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
cloud.google.com/go v0.111.0
cloud.google.com/go/compute/metadata v0.2.3
cloud.google.com/go/iam v1.1.5
github.com/golang/protobuf v1.5.3
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.5.0
github.com/googleapis/gax-go/v2 v2.12.0
Expand All @@ -27,6 +26,7 @@ require (
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/martian/v3 v3.3.2 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
Expand Down

0 comments on commit ebbb610

Please sign in to comment.