Skip to content

Commit

Permalink
ref: move test dir (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Feb 29, 2024
1 parent 202fd05 commit 4ac896e
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 30 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.21
- uses: actions/checkout@v3
go-version: 1.22
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.54.2
args: --verbose

test:
strategy:
matrix:
go-version: [1.21]
go-version: [1.22]
platform: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.platform }}

steps:
- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install goveralls
run: go install github.com/mattn/goveralls@latest

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- run: go test -v -coverprofile=coverage.out ./...

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup
uses: actions/setup-go@v3
with:
go-version: ">=1.21"
go-version: ">=1.22"
cache: true
- name: Generate Changelog Only
uses: goreleaser/goreleaser-action@v4
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
coverage
coverage.out
ginkgo.report

dist/
.task/

src/i18n/out/en-US/active.en-GB.json
test/data/research/scientist/

.DS_Store
thumbs.db
*.log
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ linters:

run:
issues-exit-code: 1
timeout: 5m
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
],
"cSpell.words": [
"bodyclose",
"cobrass",
"coverprofile",
"cubiest",
"deadcode",
Expand All @@ -21,6 +22,7 @@
"gofmt",
"goimports",
"golangci",
"gomega",
"gomnd",
"goreleaser",
"gosec",
Expand All @@ -33,17 +35,21 @@
"linters",
"mattn",
"nakedret",
"nolint",
"nolintlint",
"nosec",
"onsi",
"pixa",
"prealloc",
"repotoken",
"shogo",
"sidewalk",
"snivilised",
"staticcheck",
"structcheck",
"stylecheck",
"thelper",
"toplevel",
"tparallel",
"typecheck",
"unconvert",
Expand Down
6 changes: 3 additions & 3 deletions src/app/command/bootstrap_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package command_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok for testing

Check failure on line 4 in src/app/command/bootstrap_test.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:revive // ok for testing` is unused for linter "revive" (nolintlint)
. "github.com/onsi/gomega" //nolint:revive // ok for testing

Check failure on line 5 in src/app/command/bootstrap_test.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:revive // ok for testing` is unused for linter "revive" (nolintlint)
"github.com/snivilised/arcadia/src/app/command"
"github.com/snivilised/arcadia/src/internal/helpers"
"github.com/snivilised/extendio/xfs/utils"
Expand Down Expand Up @@ -30,7 +30,7 @@ var _ = Describe("Bootstrap", Ordered, func() {
)

BeforeAll(func() {
repo = helpers.Repo("../..")
repo = helpers.Repo("")
l10nPath = helpers.Path(repo, "test/data/l10n")
Expect(utils.FolderExists(l10nPath)).To(BeTrue())
})
Expand Down
8 changes: 4 additions & 4 deletions src/app/command/command_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package command_test
import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)

func TestCommand(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Command Suite")
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "Command Suite")
}
6 changes: 3 additions & 3 deletions src/app/command/root-cmd_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package command_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok for testing

Check failure on line 4 in src/app/command/root-cmd_test.go

View workflow job for this annotation

GitHub Actions / lint

directive `//nolint:revive // ok for testing` is unused for linter "revive" (nolintlint)
. "github.com/onsi/gomega" //nolint:revive // ok for testing

"github.com/snivilised/arcadia/src/app/command"
"github.com/snivilised/arcadia/src/internal/helpers"
Expand All @@ -16,7 +16,7 @@ var _ = Describe("RootCmd", Ordered, func() {
)

BeforeAll(func() {
repo = helpers.Repo("../..")
repo = helpers.Repo("")
l10nPath = helpers.Path(repo, "test/data/l10n")
Expect(utils.FolderExists(l10nPath)).To(BeTrue())
})
Expand Down
3 changes: 3 additions & 0 deletions src/app/command/widget-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ func (b *Bootstrap) buildWidgetCommand(container *assistant.CobraContainer) *cob
if value == defaultDirectory {
return nil
}

if _, err := os.Stat(value); err != nil {
if os.IsNotExist(err) {
return err
}
}

return nil
},
)
Expand All @@ -101,6 +103,7 @@ func (b *Bootstrap) buildWidgetCommand(container *assistant.CobraContainer) *cob
if domain.OutputFormatEnumInfo.En(value) == domain.XMLFormatEn {
return nil
}

return fmt.Errorf(
"only xml format is currently supported, other formats available in future release",
)
Expand Down
8 changes: 4 additions & 4 deletions src/app/command/widget_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package command_test
import (
"fmt"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok for testing
. "github.com/onsi/gomega" //nolint:revive // ok for testing
"github.com/spf13/cobra"

"github.com/snivilised/arcadia/src/app/command"
Expand All @@ -25,8 +25,8 @@ var _ = Describe("WidgetCmd", Ordered, func() {
)

BeforeAll(func() {
repo = helpers.Repo("../../..")
l10nPath = helpers.Path(repo, "src/test/data/l10n")
repo = helpers.Repo("")
l10nPath = helpers.Path(repo, "test/data/l10n")
Expect(utils.FolderExists(l10nPath)).To(BeTrue(),
fmt.Sprintf("💥 l10Path: '%v' does not exist", l10nPath),
)
Expand Down
8 changes: 4 additions & 4 deletions src/i18n/i18n_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package i18n_test
import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)

func TestI18n(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "I18n Suite")
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "I18n Suite")
}
19 changes: 16 additions & 3 deletions src/internal/helpers/test-utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package helpers
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"

"github.com/pkg/errors"
)

func Path(parent, relative string) string {
Expand Down Expand Up @@ -43,8 +45,19 @@ func Root() string {
}

func Repo(relative string) string {
_, filename, _, _ := runtime.Caller(0) //nolint:dogsled // use of 3 _ is out of our control
return Path(filepath.Dir(filename), relative)
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
bytes, err := cmd.Output()

if err != nil {
panic(errors.Wrap(err, "couldn't get repo root"))
}

segments := strings.Split(relative, "/")
output := strings.TrimSuffix(string(bytes), "\n")
path := []string{output}
path = append(path, segments...)

return filepath.Join(path...)
}

func Log() string {
Expand Down
2 changes: 2 additions & 0 deletions src/internal/log/new-logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func NewLogger(info *LoggerInfo) Ref {
if info.Path == "" {
panic(i18n.NewInvalidConfigEntryError(info.Path, "-"))
}

ws := zapcore.AddSync(&lumberjack.Logger{
Filename: info.Path,
MaxSize: info.Rotation.MaxSizeInMb,
Expand All @@ -29,6 +30,7 @@ func NewLogger(info *LoggerInfo) Ref {
ws,
info.Level,
)

return zap.New(core)
}, func() Logger {
return zap.NewNop()
Expand Down
File renamed without changes.

0 comments on commit 4ac896e

Please sign in to comment.