Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Hang Yan <[email protected]>
  • Loading branch information
hangyan committed Jan 14, 2025
1 parent 1782904 commit 7d990f7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/antctl/raw/supportbundle/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,21 +431,23 @@ func TestProcessResults(t *testing.T) {
},
},
}
defaultFS = afero.NewMemMapFs()
defaultFS.MkdirAll(option.dir, 0755)
defer func() {
defaultFS = afero.NewOsFs()
}()

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defaultFS = afero.NewMemMapFs()
defaultFS.MkdirAll(option.dir, 0755)
defer func() {
defaultFS = afero.NewOsFs()
}()

antreaInterface := fakeclientset.NewSimpleClientset(&controllerInfo, agentInfo1, agentInfo2)
k8sClient := fake.NewSimpleClientset(controllerPod, pod1, pod2)
require.NoError(t, processResults(context.TODO(), antreaInterface, k8sClient, tt.resultMap, option.dir))
b, err := afero.ReadFile(defaultFS, filepath.Join(option.dir, "failed_nodes"))
require.NoError(t, err)
data := string(b)
ok, checkErr := afero.Exists(defaultFS, filepath.Join(option.dir, "controllerinfo"))
require.NoError(t, checkErr)
assert.True(t, ok)
for node, err := range tt.resultMap {
tgzFileName := fmt.Sprintf("agent_%s.tar.gz", node)
if node == "" {
Expand Down Expand Up @@ -476,6 +478,7 @@ func TestProcessResults(t *testing.T) {
} else {
assert.NotContains(t, data, node)
}
defaultFS.Remove(filepath.Join(option.dir, "failed_nodes"))
}
})
}
Expand Down

0 comments on commit 7d990f7

Please sign in to comment.