|
1 | 1 | package cmd |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "context" |
4 | 5 | "path" |
5 | 6 | "testing" |
6 | 7 |
|
|
26 | 27 | line3 |
27 | 28 | `, secrets["mysecret"]) |
28 | 29 | } |
| 30 | + |
| 31 | +func TestListOptions(t *testing.T) { |
| 32 | + rootCmd := createRootCommand(context.Background(), &Input{}, "") |
| 33 | + err := newRunCommand(context.Background(), &Input{ |
| 34 | + listOptions: true, |
| 35 | + })(rootCmd, []string{}) |
| 36 | + assert.NoError(t, err) |
| 37 | +} |
| 38 | + |
| 39 | +func TestRun(t *testing.T) { |
| 40 | + rootCmd := createRootCommand(context.Background(), &Input{}, "") |
| 41 | + err := newRunCommand(context.Background(), &Input{ |
| 42 | + platforms: []string{"ubuntu-latest=node:16-buster-slim"}, |
| 43 | + workdir: "../pkg/runner/testdata/", |
| 44 | + workflowsPath: "./basic/push.yml", |
| 45 | + })(rootCmd, []string{}) |
| 46 | + assert.NoError(t, err) |
| 47 | +} |
| 48 | + |
| 49 | +func TestRunPush(t *testing.T) { |
| 50 | + rootCmd := createRootCommand(context.Background(), &Input{}, "") |
| 51 | + err := newRunCommand(context.Background(), &Input{ |
| 52 | + platforms: []string{"ubuntu-latest=node:16-buster-slim"}, |
| 53 | + workdir: "../pkg/runner/testdata/", |
| 54 | + workflowsPath: "./basic/push.yml", |
| 55 | + })(rootCmd, []string{"push"}) |
| 56 | + assert.NoError(t, err) |
| 57 | +} |
| 58 | + |
| 59 | +func TestRunPushJsonLogger(t *testing.T) { |
| 60 | + rootCmd := createRootCommand(context.Background(), &Input{}, "") |
| 61 | + err := newRunCommand(context.Background(), &Input{ |
| 62 | + platforms: []string{"ubuntu-latest=node:16-buster-slim"}, |
| 63 | + workdir: "../pkg/runner/testdata/", |
| 64 | + workflowsPath: "./basic/push.yml", |
| 65 | + jsonLogger: true, |
| 66 | + })(rootCmd, []string{"push"}) |
| 67 | + assert.NoError(t, err) |
| 68 | +} |
| 69 | + |
| 70 | +func TestFlags(t *testing.T) { |
| 71 | + for _, f := range []string{"graph", "list", "bug-report", "man-page"} { |
| 72 | + t.Run("TestFlag-"+f, func(t *testing.T) { |
| 73 | + rootCmd := createRootCommand(context.Background(), &Input{}, "") |
| 74 | + err := rootCmd.Flags().Set(f, "true") |
| 75 | + assert.NoError(t, err) |
| 76 | + err = newRunCommand(context.Background(), &Input{ |
| 77 | + platforms: []string{"ubuntu-latest=node:16-buster-slim"}, |
| 78 | + workdir: "../pkg/runner/testdata/", |
| 79 | + workflowsPath: "./basic/push.yml", |
| 80 | + })(rootCmd, []string{}) |
| 81 | + assert.NoError(t, err) |
| 82 | + }) |
| 83 | + } |
| 84 | +} |
0 commit comments