diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ac3cf05..fc703bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,8 +6,12 @@ permissions: jobs: test: - runs-on: ubuntu-latest + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} steps: + - uses: Homebrew/actions/setup-homebrew@master - uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/coyote_test.go b/coyote_test.go index aa84ed4..570a92c 100644 --- a/coyote_test.go +++ b/coyote_test.go @@ -45,16 +45,26 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) { } func InitializeScenario(ctx *godog.ScenarioContext) { - ctx.Given(`^coyote is present$`, coyoteIsPresent) + ctx.Given(`^coyote is present locally$`, coyoteIsPresentLocally) + ctx.Given(`^brew is present$`, brewIsPresent) + ctx.When(`^coyote is run with help option$`, coyoteIsRunWithHelpOption) + ctx.When(`^"(.+)" is installed using brew$`, formulaIsInstalledUsingBrew) + ctx.Then(`^help message is printed$`, helpMessageIsPrinted) + ctx.Then(`^coyote is installed$`, coyoteIsInstalled) } -func coyoteIsPresent() error { +func coyoteIsPresentLocally() error { _, err := os.Stat("coyote") return err } +func brewIsPresent() error { + _, err := exec.LookPath("brew") + return err +} + func coyoteIsRunWithHelpOption(ctx context.Context) (context.Context, error) { out, err := exec.Command("./coyote", "-h").Output() if err != nil { @@ -63,6 +73,14 @@ func coyoteIsRunWithHelpOption(ctx context.Context) (context.Context, error) { return context.WithValue(ctx, ctxKey{}, string(out)), nil } +func formulaIsInstalledUsingBrew(formula string) error { + cmd := exec.Command("brew", "install", formula) + if err := cmd.Run(); err != nil { + return err + } + return nil +} + func helpMessageIsPrinted(ctx context.Context) error { actualOutput := ctx.Value(ctxKey{}).(string) @@ -72,6 +90,11 @@ func helpMessageIsPrinted(ctx context.Context) error { return fmt.Errorf("Result not as expected:\n%v", diff.LineDiff(expectedOutput, actualOutput)) } +func coyoteIsInstalled() error { + _, err := exec.LookPath("coyote") + return err +} + const expectedOutput = `NAME: coyote - Coyote is a RabbitMQ message sink. diff --git a/features/coyote.feature b/features/coyote.feature deleted file mode 100644 index 1a31860..0000000 --- a/features/coyote.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: run coyote - - Scenario: Smoke test - Given coyote is present - When coyote is run with help option - Then help message is printed diff --git a/features/help.feature b/features/help.feature new file mode 100644 index 0000000..7a68e8c --- /dev/null +++ b/features/help.feature @@ -0,0 +1,6 @@ +Feature: Run coyote + + Scenario: Coyote displays help message + Given coyote is present locally + When coyote is run with help option + Then help message is printed diff --git a/features/install.feature b/features/install.feature new file mode 100644 index 0000000..32ad23b --- /dev/null +++ b/features/install.feature @@ -0,0 +1,6 @@ +Feature: Install coyote + + Scenario: Homebrew installs coyote + Given brew is present + When "ghokun/tap/coyote" is installed using brew + Then coyote is installed