Skip to content

Commit eb21f30

Browse files
mathetakedeva26
andauthored
e2e fix and manifest changes (#43)
Signed-off-by: Takeshi Yoneda <[email protected]> Co-authored-by: Devarajan Ramaswamy <[email protected]>
1 parent 5994e78 commit eb21f30

35 files changed

+318
-788
lines changed

api/manifest_util_test.go

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io/ioutil"
77
"testing"
88

9-
"github.com/stretchr/testify/assert"
109
"github.com/stretchr/testify/require"
1110
)
1211

@@ -47,9 +46,9 @@ func Test_parseManifestEOLDate(t *testing.T) {
4746
a, err := parseManifestEOLDate(c.in)
4847
require.NoError(t, err)
4948
y, m, d := a.Date()
50-
assert.Equal(t, c.expYear, y)
51-
assert.Equal(t, c.expMonth, int(m))
52-
assert.Equal(t, c.expDay, d)
49+
require.Equal(t, c.expYear, y)
50+
require.Equal(t, c.expMonth, int(m))
51+
require.Equal(t, c.expDay, d)
5352
}
5453
})
5554
}
@@ -84,7 +83,7 @@ func TestIstioDistribution_ToString(t *testing.T) {
8483
exp: "1.8.3-istio-v0",
8584
},
8685
} {
87-
assert.Equal(t, c.exp, c.in.ToString())
86+
require.Equal(t, c.exp, c.in.ToString())
8887
}
8988
}
9089

@@ -124,7 +123,7 @@ func TestIstioDistributionEqual(t *testing.T) {
124123
exp: false,
125124
},
126125
} {
127-
assert.Equal(t, c.exp, c.in.Equal(operand))
126+
require.Equal(t, c.exp, c.in.Equal(operand))
128127
}
129128
}
130129

@@ -154,12 +153,12 @@ func TestIstioDistribution_ExistInManifest(t *testing.T) {
154153

155154
ok, err := d.ExistInManifest(ms)
156155
require.NoError(t, err)
157-
assert.True(t, ok)
156+
require.True(t, ok)
158157

159158
d.FlavorVersion--
160159
ok, err = d.ExistInManifest(ms)
161160
require.NoError(t, err)
162-
assert.False(t, ok)
161+
require.False(t, ok)
163162
}
164163

165164
func TestIstioDistribution_Group(t *testing.T) {
@@ -173,14 +172,14 @@ func TestIstioDistribution_Group(t *testing.T) {
173172
} {
174173
actual, err := c.in.Group()
175174
require.NoError(t, err)
176-
assert.Equal(t, c.exp, actual)
175+
require.Equal(t, c.exp, actual)
177176
}
178177
}
179178

180179
func TestIstioDistribution_IsUpstream(t *testing.T) {
181-
assert.True(t, (&IstioDistribution{Flavor: "istio"}).IsUpstream())
182-
assert.False(t, (&IstioDistribution{Flavor: "tetrate"}).IsUpstream())
183-
assert.False(t, (&IstioDistribution{Flavor: "tetratefips"}).IsUpstream())
180+
require.True(t, (&IstioDistribution{Flavor: "istio"}).IsUpstream())
181+
require.False(t, (&IstioDistribution{Flavor: "tetrate"}).IsUpstream())
182+
require.False(t, (&IstioDistribution{Flavor: "tetratefips"}).IsUpstream())
184183
}
185184

186185
func TestIstioDistribution_GreaterThan(t *testing.T) {
@@ -192,7 +191,7 @@ func TestIstioDistribution_GreaterThan(t *testing.T) {
192191
} {
193192
actual, err := base.GreaterThan(c)
194193
require.NoError(t, err)
195-
assert.True(t, actual)
194+
require.True(t, actual)
196195
}
197196
})
198197

@@ -203,15 +202,15 @@ func TestIstioDistribution_GreaterThan(t *testing.T) {
203202
} {
204203
actual, err := base.GreaterThan(c)
205204
require.NoError(t, err)
206-
assert.False(t, actual)
205+
require.False(t, actual)
207206
}
208207
})
209208
}
210209

211210
func TestIstioDistribution_Equal(t *testing.T) {
212211
base := &IstioDistribution{Version: "1.2.3", Flavor: "tetrate", FlavorVersion: 40}
213212
t.Run("true", func(t *testing.T) {
214-
assert.True(t, base.Equal(&IstioDistribution{Version: "1.2.3", Flavor: "tetrate", FlavorVersion: 40}))
213+
require.True(t, base.Equal(&IstioDistribution{Version: "1.2.3", Flavor: "tetrate", FlavorVersion: 40}))
215214
})
216215

217216
t.Run("false", func(t *testing.T) {
@@ -249,7 +248,7 @@ func TestIstioDistributionFromString(t *testing.T) {
249248
} {
250249
v, err := IstioDistributionFromString(c.in)
251250
require.NoError(t, err, c.in, c.in)
252-
assert.Equal(t, c.exp, v)
251+
require.Equal(t, c.exp, v)
253252
}
254253
})
255254

@@ -260,7 +259,7 @@ func TestIstioDistributionFromString(t *testing.T) {
260259
"1.6.7-tetrate-v", "1.7.113-tetrate-",
261260
} {
262261
_, err := IstioDistributionFromString(in)
263-
assert.Error(t, err, in)
262+
require.Error(t, err, in)
264263
}
265264
})
266265
}
@@ -277,8 +276,8 @@ func Test_parseFlavor(t *testing.T) {
277276
} {
278277
flavor, flavorVersion, err := parseFlavor(c.in)
279278
require.NoError(t, err)
280-
assert.Equal(t, c.flavor, flavor)
281-
assert.Equal(t, c.flavorVersion, flavorVersion)
279+
require.Equal(t, c.flavor, flavor)
280+
require.Equal(t, c.flavorVersion, flavorVersion)
282281
}
283282
})
284283

@@ -572,13 +571,13 @@ func TestGetLatestDistribution(t *testing.T) {
572571
for _, test := range tests {
573572
t.Run(test.name, func(t *testing.T) {
574573
latest, isSecure, err := GetLatestDistribution(test.current, test.maniest)
575-
assert.NoError(t, err)
574+
require.NoError(t, err)
576575
if latest == nil {
577-
assert.Equal(t, latest, test.wants)
576+
require.Equal(t, latest, test.wants)
578577
} else {
579-
assert.True(t, latest.Equal(test.wants))
578+
require.True(t, latest.Equal(test.wants))
580579
}
581-
assert.Equal(t, test.wantsSecure, isSecure)
580+
require.Equal(t, test.wantsSecure, isSecure)
582581
})
583582
}
584583
}

cmd/fetch_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import (
1818
"fmt"
1919
"testing"
2020

21-
"github.com/stretchr/testify/assert"
22-
21+
"github.com/stretchr/testify/require"
2322
"github.com/tetratelabs/getmesh/api"
2423
)
2524

@@ -139,10 +138,10 @@ func Test_fetchParams(t *testing.T) {
139138
t.Run(fmt.Sprintf("%d-th case", i), func(t *testing.T) {
140139
actual, err := fetchParams(c.flag, c.mf)
141140
if c.exp == nil {
142-
assert.Error(t, err)
141+
require.Error(t, err)
143142
} else {
144-
assert.NoError(t, err)
145-
assert.Equal(t, c.exp, actual)
143+
require.NoError(t, err)
144+
require.Equal(t, c.exp, actual)
146145
}
147146
})
148147

cmd/gen_ca_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/spf13/pflag"
2626
"github.com/stretchr/testify/require"
27-
"gotest.tools/assert"
2827
v1 "k8s.io/api/core/v1"
2928
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3029
"k8s.io/client-go/kubernetes/fake"
@@ -58,7 +57,7 @@ func TestPreFlightChecks(t *testing.T) {
5857
cfg.SetDefaultValues()
5958
cfg.DisableSecretCreation = false
6059
err := genCAPreFlightChecks(cfg, cs)
61-
assert.ErrorContains(t, err, "namespaces \"istio-system\" not found")
60+
require.Contains(t, err.Error(), "namespaces \"istio-system\" not found")
6261

6362
ns := &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "istio-system"}}
6463
_, err = cs.CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{})
@@ -76,21 +75,21 @@ func TestPreFlightChecks(t *testing.T) {
7675
cs := fake.NewSimpleClientset()
7776
cfg := &config.Config{}
7877
cfg.DisableSecretCreation = true
79-
assert.Equal(t, genCAPreFlightChecks(cfg, cs), nil)
78+
require.Equal(t, genCAPreFlightChecks(cfg, cs), nil)
8079

8180
// readonly error
8281
ro := filepath.Join(d, "readonly")
8382
require.NoError(t, os.Mkdir(ro, 0400))
8483
cfg.CertParameters.SecretFilePath = filepath.Join(ro, "test.yaml")
8584
err = genCAPreFlightChecks(cfg, cs)
86-
assert.ErrorContains(t, err, "unable to write on secret file path:")
85+
require.Contains(t, err.Error(), "unable to write on secret file path:")
8786

8887
// ok
8988
f, err := ioutil.TempFile(d, "")
9089
require.NoError(t, err)
9190
cfg.CertParameters.SecretFilePath = f.Name()
9291
err = genCAPreFlightChecks(cfg, cs)
93-
assert.ErrorContains(t, err, f.Name()+"` already exist, please change the file path before proceeding")
92+
require.Contains(t, err.Error(), f.Name()+"` already exist, please change the file path before proceeding")
9493
})
9594
}
9695

@@ -115,7 +114,7 @@ func TestFetchParametersError(t *testing.T) {
115114
t.Run(c.label, func(t *testing.T) {
116115
require.NoError(t, flags.Parse(c.arguments))
117116
_, err := genCAFetchParameters(flags)
118-
assert.ErrorContains(t, err, c.expected)
117+
require.Contains(t, err.Error(), c.expected)
119118
})
120119
}
121120
}
@@ -250,7 +249,7 @@ func TestFetchParametersSucess(t *testing.T) {
250249
// so explicit error checks aren't required
251250
cfg, err := genCAFetchParameters(flags)
252251
require.NoError(t, err)
253-
assert.Equal(t, true, c.checker(cfg))
252+
require.Equal(t, true, c.checker(cfg))
254253
})
255254
}
256255
}

cmd/istioctl_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"os"
2121
"testing"
2222

23-
"github.com/stretchr/testify/assert"
2423
"github.com/stretchr/testify/require"
2524

2625
"github.com/tetratelabs/getmesh/api"
@@ -103,7 +102,7 @@ func TestIstioctl_istioctlArgChecks(t *testing.T) {
103102
require.Error(t, err)
104103
})
105104

106-
assert.Contains(t, buf.String(), "Your active istioctl of version 1.7.4-tetratefips-v0 is deprecated.")
105+
require.Contains(t, buf.String(), "Your active istioctl of version 1.7.4-tetratefips-v0 is deprecated.")
107106
t.Log(buf.String())
108107
})
109108
}
@@ -172,7 +171,7 @@ func TestIstioctl_istioctlParsePreCheckArgs(t *testing.T) {
172171
for _, c := range cases {
173172
t.Run(c.name, func(t *testing.T) {
174173
actual := istioctlParsePreCheckArgs(c.args)
175-
assert.Equal(t, c.exp, actual)
174+
require.Equal(t, c.exp, actual)
176175
})
177176
}
178177
}
@@ -247,7 +246,7 @@ func TestIstioctl_istioctlParseVerifyInstallArgs(t *testing.T) {
247246
for _, c := range cases {
248247
t.Run(c.name, func(t *testing.T) {
249248
actual := istioctlParseVerifyInstallArgs(c.args)
250-
assert.Equal(t, c.exp, actual)
249+
require.Equal(t, c.exp, actual)
251250
})
252251
}
253252
}
@@ -277,7 +276,7 @@ func TestIstioctl_istioctPatchVersionCheck(t *testing.T) {
277276
require.Error(t, istioctlPatchVersionCheck(current, m))
278277
})
279278

280-
assert.Contains(t, buf.String(), "your current patch version 1.7.5 is not the latest version 1.7.6")
279+
require.Contains(t, buf.String(), "your current patch version 1.7.5 is not the latest version 1.7.6")
281280
t.Log(buf.String())
282281
})
283282

@@ -379,7 +378,7 @@ func TestIstioctl_istioctlPreProcessArgs(t *testing.T) {
379378
for _, test := range tests {
380379
t.Run(test.name, func(t *testing.T) {
381380
actual := istioctlPreProcessArgs(test.args)
382-
assert.Equal(t, test.wants, actual)
381+
require.Equal(t, test.wants, actual)
383382
})
384383
}
385384
}

cmd/prune_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"strconv"
1919
"testing"
2020

21-
"github.com/stretchr/testify/assert"
2221
"github.com/stretchr/testify/require"
2322

2423
"github.com/tetratelabs/getmesh/api"
@@ -50,7 +49,7 @@ func Test_pruneCheckFlags(t *testing.T) {
5049
} else {
5150
require.NoError(t, err)
5251
}
53-
assert.Equal(t, c.exp, actual)
52+
require.Equal(t, c.exp, actual)
5453
})
5554
}
5655
}

cmd/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ func NewRoot(version, homeDir string) *cobra.Command {
8989
cmd.AddCommand(newShowCmd(homeDir))
9090
cmd.AddCommand(newConfigValidateCmd(homeDir))
9191
cmd.AddCommand(newGenCACmd())
92-
cmd.AddCommand(newUpgradeCmd(version))
9392
cmd.AddCommand(newPruneCmd(homeDir))
9493
cmd.AddCommand(newSetDefaultHubCmd(homeDir))
9594

cmd/switch_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"strings"
2222
"testing"
2323

24-
"github.com/stretchr/testify/assert"
2524
"github.com/stretchr/testify/require"
2625

2726
"github.com/tetratelabs/getmesh/api"
@@ -88,21 +87,21 @@ func Test_switchParse(t *testing.T) {
8887
distro, err := switchParse(home, flag)
8988
require.NoError(t, err)
9089
exp := &api.IstioDistribution{Version: "1.7.6", Flavor: "istio", FlavorVersion: 0}
91-
assert.Equal(t, distro, exp)
90+
require.Equal(t, distro, exp)
9291
})
9392
t.Run("name", func(t *testing.T) {
9493
flag := &switchFlags{name: "1.8.3-istio-v0"}
9594
distro, err := switchParse(home, flag)
9695
require.NoError(t, err)
9796
exp := &api.IstioDistribution{Version: "1.8.3", Flavor: "istio", FlavorVersion: 0}
98-
assert.Equal(t, distro, exp)
97+
require.Equal(t, distro, exp)
9998
})
10099
t.Run("group", func(t *testing.T) {
101100
flag := &switchFlags{version: "1.7", flavor: "istio", flavorVersion: 0}
102101
distro, err := switchParse(home, flag)
103102
require.NoError(t, err)
104103
exp := &api.IstioDistribution{Version: "1.7.6", Flavor: "istio", FlavorVersion: 0}
105-
assert.Equal(t, distro, exp)
104+
require.Equal(t, distro, exp)
106105
})
107106
}
108107

@@ -135,6 +134,6 @@ func Test_switchHandleDistro(t *testing.T) {
135134
} {
136135
v, err := switchHandleDistro(c.curr, c.flags)
137136
require.NoError(t, err)
138-
assert.Equal(t, c.exp, v)
137+
require.Equal(t, c.exp, v)
139138
}
140139
}

cmd/upgrade.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)