-
Notifications
You must be signed in to change notification settings - Fork 122
/
runhelp.go
81 lines (72 loc) · 1.79 KB
/
runhelp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (c) Contributors to the Apptainer project, established as
// Apptainer a Series of LF Projects LLC.
// For website terms of use, trademark policy, privacy policy and other
// project policies see https://lfprojects.org/policies
// Copyright (c) 2019, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
package runhelp
import (
"testing"
"github.com/apptainer/apptainer/e2e/internal/e2e"
"github.com/apptainer/apptainer/e2e/internal/testhelper"
)
type ctx struct {
env e2e.TestEnv
}
func (c ctx) testRunHelp(t *testing.T) {
e2e.EnsureImage(t, c.env)
tests := []struct {
name string
argv []string
output string
exit int
}{
{
name: "DefaultHelp",
argv: []string{c.env.ImagePath},
output: "BAD_GUY=Thanos",
exit: 0,
},
{
name: "AppFooHelp",
argv: []string{"--app", "foo", c.env.ImagePath},
output: "This is the help for foo!",
exit: 0,
},
{
name: "AppFakeHelp",
argv: []string{"--app", "fake", c.env.ImagePath},
output: "No help sections were defined for this image",
exit: 0,
},
{
name: "NoImage",
argv: []string{"/fake/image"},
exit: 255,
},
}
for _, tt := range tests {
c.env.RunApptainer(
t,
e2e.AsSubtest(tt.name),
e2e.WithProfile(e2e.UserProfile),
e2e.WithCommand("run-help"),
e2e.WithArgs(tt.argv...),
e2e.ExpectExit(
tt.exit,
e2e.ExpectOutput(e2e.ContainMatch, tt.output),
),
)
}
}
// E2ETests is the main func to trigger the test suite
func E2ETests(env e2e.TestEnv) testhelper.Tests {
c := ctx{
env: env,
}
return testhelper.Tests{
"run-help command": c.testRunHelp,
}
}