...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package bigquery
16
17 import (
18 "testing"
19
20 "cloud.google.com/go/iam/apiv1/iampb"
21 "cloud.google.com/go/internal/testutil"
22 bq "google.golang.org/api/bigquery/v2"
23 )
24
25 func TestPolicyConversions(t *testing.T) {
26
27 for _, test := range []struct {
28 bq *bq.Policy
29 iam *iampb.Policy
30 }{
31 {&bq.Policy{}, &iampb.Policy{}},
32 {
33 &bq.Policy{
34 Bindings: []*bq.Binding{
35 {
36 Role: "foo",
37 Members: []string{"a", "b", "c"},
38 },
39 },
40 Etag: "etag",
41 Version: 1,
42 },
43 &iampb.Policy{
44 Bindings: []*iampb.Binding{
45 {
46 Role: "foo",
47 Members: []string{"a", "b", "c"},
48 },
49 },
50 Etag: []byte("etag"),
51 Version: 1,
52 },
53 },
54 } {
55 gotIAM := iamFromBigQueryPolicy(test.bq)
56 if diff := testutil.Diff(gotIAM, test.iam); diff != "" {
57 t.Errorf("%+v:\n, -got, +want:\n%s", test.iam, diff)
58 }
59
60 gotBQ := iamToBigQueryPolicy(test.iam)
61 if diff := testutil.Diff(gotBQ, test.bq); diff != "" {
62 t.Errorf("%+v:\n, -got, +want:\n%s", test.iam, diff)
63 }
64 }
65 }
66
View as plain text