MCPcopy
hub / github.com/argoproj/argo-workflows / TestChmod

Function TestChmod

workflow/executor/executor_test.go:328–382  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

326}
327
328func TestChmod(t *testing.T) {
329 if runtime.GOOS == "windows" {
330 t.Skip("chmod does not work in windows")
331 }
332
333 type perm struct {
334 dir string
335 file string
336 }
337
338 tests := []struct {
339 mode int32
340 recurse bool
341 permissions perm
342 }{
343 {
344 0o777,
345 false,
346 perm{
347 "drwxrwxrwx",
348 "-rw-------",
349 },
350 },
351 {
352 0o777,
353 true,
354 perm{
355 "drwxrwxrwx",
356 "-rwxrwxrwx",
357 },
358 },
359 }
360
361 for _, test := range tests {
362 // Setup directory and file for testing
363 tempDir := t.TempDir()
364
365 tempFile, err := os.CreateTemp(tempDir, "chmod-file-test")
366 require.NoError(t, err)
367
368 // Run chmod function
369 err = chmod(tempDir, test.mode, test.recurse)
370 require.NoError(t, err)
371
372 // Check directory mode if set
373 dirPermission, err := os.Stat(tempDir)
374 require.NoError(t, err)
375 assert.Equal(t, dirPermission.Mode().String(), test.permissions.dir)
376
377 // Check file mode mode if set
378 filePermission, err := os.Stat(tempFile.Name())
379 require.NoError(t, err)
380 assert.Equal(t, filePermission.Mode().String(), test.permissions.file)
381 }
382}
383
384func TestSaveArtifacts(t *testing.T) {
385 fakeClientset := fake.NewSimpleClientset()

Callers

nothing calls this directly

Calls 3

chmodFunction · 0.85
StringMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected