Skip to content

Commit

Permalink
Merge pull request #85 from grafana/fix-unit-tests-on-macos
Browse files Browse the repository at this point in the history
Fix unit tests on macos
  • Loading branch information
pablochacin authored Dec 7, 2022
2 parents ef4c5a7 + 4c4dd1e commit 18af6ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ on:

jobs:
build-with-xk6:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -26,7 +29,10 @@ jobs:
xk6 build --with $(go list -m)=.
run-unit-tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/process/fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ func Test_FakeExecutor(t *testing.T) {
},
{
title: "command without arguments",
cmdLine: "/bin/true",
cmdLine: "true",
out: []byte{},
err: nil,
},
{
title: "command returning error",
cmdLine: "/bin/false",
cmdLine: "false",
out: []byte{},
err: fmt.Errorf("command exited with rc 1"),
},
Expand Down Expand Up @@ -157,13 +157,13 @@ func Test_Callbacks(t *testing.T) {
},
{
title: "command without arguments",
cmdLine: "/bin/true",
cmdLine: "true",
out: []byte{},
err: nil,
},
{
title: "command returning error",
cmdLine: "/bin/false",
cmdLine: "false",
out: []byte{},
err: fmt.Errorf("command exited with rc 1"),
},
Expand Down
16 changes: 8 additions & 8 deletions pkg/utils/process/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ func Test_Exec(t *testing.T) {
},
{
title: "return stderr",
cmd: "/bin/bash",
args: []string{"-c", "echo -n 'hello world' 2>&1"},
cmd: "sh",
args: []string{"-c", "echo hello world 2>&1"},
expectError: false,
expectOutput: "hello world",
expectOutput: "hello world\n",
},
{
title: "do not return output",
cmd: "/bin/true",
cmd: "true",
expectError: false,
expectOutput: "",
},
{
title: "command return error code",
cmd: "/bin/false",
cmd: "false",
expectError: true,
expectOutput: "",
},
{
title: "return error code and stderr",
cmd: "/bin/bash",
args: []string{"-c", "echo -n 'hello world' 2>&1; kill -KILL $$"},
cmd: "sh",
args: []string{"-c", "echo hello world 2>&1; kill -KILL $$"},
expectError: true,
expectOutput: "hello world",
expectOutput: "hello world\n",
},
}

Expand Down

0 comments on commit 18af6ef

Please sign in to comment.