From 0ca358d3cffb7d9f4a430a0ddfa1b60307e2aeaa Mon Sep 17 00:00:00 2001 From: Tronje Krop Date: Mon, 5 Jan 2026 07:46:25 +0100 Subject: [PATCH] chore: switch test names from space to hyphen separated (#140) Signed-off-by: Tronje Krop --- cmd/mock/main_test.go | 2 +- gock/controller_test.go | 10 +- gock/store_test.go | 10 +- internal/maps/maps_test.go | 14 +-- internal/mock/builder_test.go | 20 ++-- internal/mock/generate_test.go | 4 +- internal/mock/loader_test.go | 70 ++++++------- internal/mock/models_test.go | 20 ++-- internal/mock/parser_test.go | 106 ++++++++++---------- internal/mock/template_test.go | 4 +- internal/reflect/random_test.go | 22 ++--- mock/matcher_test.go | 120 +++++++++++------------ mock/mocks_test.go | 16 +-- reflect/reflect_test.go | 168 ++++++++++++++++---------------- test/common_test.go | 78 +++++++-------- test/context_test.go | 18 ++-- test/pattern_test.go | 132 ++++++++++++------------- test/reporter_test.go | 98 +++++++++---------- test/runner_test.go | 92 ++++++++--------- 19 files changed, 502 insertions(+), 502 deletions(-) diff --git a/cmd/mock/main_test.go b/cmd/mock/main_test.go index 753f83d..a5ff5d7 100644 --- a/cmd/mock/main_test.go +++ b/cmd/mock/main_test.go @@ -7,7 +7,7 @@ import ( ) var mainTestCases = map[string]test.MainParams{ - "no mocks": { + "no-mocks": { Args: []string{"mock"}, Env: []string{}, ExitCode: 0, diff --git a/gock/controller_test.go b/gock/controller_test.go index 61df87b..56003db 100644 --- a/gock/controller_test.go +++ b/gock/controller_test.go @@ -18,23 +18,23 @@ type ControllerParams struct { } var controllerTestCases = map[string]ControllerParams{ - "match with bar": { + "match-with-bar": { url: "http://foo.com/bar", expectMatch: test.Success, }, - "match with baz": { + "match-with-baz": { url: "http://foo.com/baz", expectMatch: test.Success, }, - "missing host": { + "missing-host": { url: "http://bar.com/baz", expectError: gock.ErrCannotMatch, }, - "missing path": { + "missing-path": { url: "http://foo.com/foo", expectError: gock.ErrCannotMatch, }, - "missing schema": { + "missing-schema": { url: "https://foo.com/bar", expectError: assert.AnError, }, diff --git a/gock/store_test.go b/gock/store_test.go index 8794e00..13c92bb 100644 --- a/gock/store_test.go +++ b/gock/store_test.go @@ -198,21 +198,21 @@ type MatchParams struct { } var matchTestCases = map[string]MatchParams{ - "match with bar": { + "match-with-bar": { url: "http://foo.com/bar", expectMatch: true, }, - "match with baz": { + "match-with-baz": { url: "http://foo.com/baz", expectMatch: true, }, - "missing host": { + "missing-host": { url: "http://bar.com/baz", }, - "missing path": { + "missing-path": { url: "http://foo.com/foo", }, - "missing schema": { + "missing-schema": { url: "https://foo.com/bar", expectError: assert.AnError, }, diff --git a/internal/maps/maps_test.go b/internal/maps/maps_test.go index e4f71bb..7b35443 100644 --- a/internal/maps/maps_test.go +++ b/internal/maps/maps_test.go @@ -15,15 +15,15 @@ type CopyParams struct { } var copyTestCases = map[string]CopyParams{ - "empty map": { + "empty-map": { input: map[string]int{}, expect: map[string]int{}, }, - "single key-value pair": { + "single-key-value-pair": { input: map[string]int{"a": 1}, expect: map[string]int{"a": 1}, }, - "multiple key-value pairs": { + "multiple-key-value-pairs": { input: map[string]int{"a": 1, "b": 2, "c": 3}, expect: map[string]int{"a": 1, "b": 2, "c": 3}, }, @@ -47,22 +47,22 @@ type AddParams struct { } var addTestCases = map[string]AddParams{ - "no sources": { + "no-sources": { target: map[string]int{"a": 1}, sources: []map[string]int{}, expect: map[string]int{"a": 1}, }, - "single source": { + "single-source": { target: map[string]int{"a": 1}, sources: []map[string]int{{"b": 2}}, expect: map[string]int{"a": 1, "b": 2}, }, - "multiple sources with no conflicts": { + "multiple-sources-with-no-conflicts": { target: map[string]int{"a": 1}, sources: []map[string]int{{"b": 2}, {"c": 3}}, expect: map[string]int{"a": 1, "b": 2, "c": 3}, }, - "multiple sources with conflicts": { + "multiple-sources-with-conflicts": { target: map[string]int{"a": 1}, sources: []map[string]int{{"a": 2}, {"a": 3, "b": 4}}, expect: map[string]int{"a": 3, "b": 4}, diff --git a/internal/mock/builder_test.go b/internal/mock/builder_test.go index 877f338..5493dee 100644 --- a/internal/mock/builder_test.go +++ b/internal/mock/builder_test.go @@ -31,20 +31,20 @@ type FileBuilderParams struct { } var fileBuilderTestCases = map[string]FileBuilderParams{ - "import double": { + "import-double": { setup: test.Panic(NewErrAliasConflict( importMockTest, pathTest)), target: targetMockIFace, imports: []*Import{importMockTest, importMockTest}, }, - "import illegal": { + "import-illegal": { setup: test.Panic(NewErrIllegalImport(importIllegal)), target: targetMockIFace, imports: []*Import{importIllegal}, }, - "no imports": { + "no-imports": { target: targetMockIFace, mocks: []*Mock{{ Methods: methodsLoadIFace, @@ -60,7 +60,7 @@ var fileBuilderTestCases = map[string]FileBuilderParams{ }, }, - "others imported": { + "others-imported": { target: targetMockIFace, imports: []*Import{ ImportReflect, ImportGomock, ImportMock, @@ -80,7 +80,7 @@ var fileBuilderTestCases = map[string]FileBuilderParams{ }, }, - "pre imported": { + "pre-imported": { target: targetMockIFace, imports: []*Import{ ImportReflect, importTest, importMock, importMockTest, @@ -99,7 +99,7 @@ var fileBuilderTestCases = map[string]FileBuilderParams{ }, }, - "alias imported": { + "alias-imported": { target: targetMockIFace, imports: []*Import{importAlias(pkgTest)}, mocks: []*Mock{{ @@ -118,7 +118,7 @@ var fileBuilderTestCases = map[string]FileBuilderParams{ }, }, - "package imported": { + "package-imported": { target: targetMockIFace, imports: []*Import{ importAlias(pkgTest), @@ -143,7 +143,7 @@ var fileBuilderTestCases = map[string]FileBuilderParams{ }, }, - "internal imported": { + "internal-imported": { target: targetMockIFace, imports: []*Import{ importAlias(pkgTest), @@ -168,7 +168,7 @@ var fileBuilderTestCases = map[string]FileBuilderParams{ }, }, - "organization imported": { + "organization-imported": { target: targetMockIFace, imports: []*Import{ importAlias(pkgTest), @@ -197,7 +197,7 @@ var fileBuilderTestCases = map[string]FileBuilderParams{ }, }, - "import conflict": { + "import-conflict": { setup: test.Panic(NewErrAliasConflict(&Import{ Alias: aliasGitHub, Path: pathTest, }, pathTest)), diff --git a/internal/mock/generate_test.go b/internal/mock/generate_test.go index c4ffe37..1ee561b 100644 --- a/internal/mock/generate_test.go +++ b/internal/mock/generate_test.go @@ -41,7 +41,7 @@ var generateTestCases = map[string]GenerateParams{ expectFile: expectIFace, }, - "failure parsing": { + "failure-parsing": { file: filepath.Join(testDirGenerate, MockFileDefault), args: []string{pathUnknown}, expectStderr: NewErrArgFailure(3, ".", @@ -54,7 +54,7 @@ var generateTestCases = map[string]GenerateParams{ expectCode: 1, }, - "failure opening": { + "failure-opening": { file: fileFailure, args: []string{pathTest}, expectStderr: NewErrFileOpening(fileFailure, &fs.PathError{ diff --git a/internal/mock/loader_test.go b/internal/mock/loader_test.go index 9a2234c..dee9a35 100644 --- a/internal/mock/loader_test.go +++ b/internal/mock/loader_test.go @@ -65,120 +65,120 @@ var loaderSearchTestCases = map[string]LoaderSearchParams{ expect: targetMockTest, }, - "package default": { + "package-default": { loader: loaderMock, target: typeFileDflt, expect: targetMockTest.With(typeFileDflt), }, - "package replace": { + "package-replace": { loader: loaderMock, target: typeFileDflt.With(&Type{Package: pkgTest}), expect: targetMockTest.With(typeFileDflt), }, - "package match": { + "package-match": { loader: loaderMock, target: typeFileIFaceX.With(typePkgTest), expect: targetTest.With(typePathTestX).With(typeFileIFaceX), }, - "package match test": { + "package-match-test": { loader: loaderMock, target: typeFileIFaceX.With(typePkgTestTest), expect: targetTestTest.With(typePathTestX).With(typeFileIFaceX), }, - "package unknown": { + "package-unknown": { loader: loaderMock, target: typeFileDirFileX.With(typePkgUnknown), expect: targetUnknown.With(typeFileDirFileX), }, - "package unknown test": { + "package-unknown-test": { loader: loaderMock, target: typeFileDirFileX.With(typePkgUnknownTest), expect: targetUnknownTest.With(typeFileDirFileX), }, - "package internal": { + "package-internal": { loader: loaderMock, target: typeFileUpX.With(typePkgInternal), expect: targetInternal.With(typeFileUpX), }, - "package internal test": { + "package-internal-test": { loader: loaderMock, target: typeFileUpX.With(typePkgInternalTest), expect: targetInternalTest.With(typeFileUpX), }, - "file package": { + "file-package": { loader: loaderMock, target: typeFilePkg, expect: targetTestTest.With(typeFilePkg), }, - "file iface": { + "file-iface": { loader: loaderMock, target: typeFileIFace, expect: targetTestTest.With(typeFileIFace), }, - "file child-missing": { + "file-child-missing": { loader: loaderMock, target: typeFileTestX, expect: targetTestTest.With(typeFileTestX), }, - "file missing": { + "file-missing": { loader: loaderMock, target: typeFileDirX, expect: targetInternalTest.With(typeFileDirX), }, - "file parent-missing": { + "file-parent-missing": { loader: loaderMock, target: typeFileUpX, expect: targetInternalTest.With(typeFileUpX), }, - "file top-missing": { + "file-top-missing": { loader: loaderMock, target: typeFileTopX, expect: (&Type{}).With(typeFileTopX), }, - "path default": { + "path-default": { loader: loaderMock, target: typePathDflt, expect: targetMockTest, }, - "path package replace": { + "path-package-replace": { loader: loaderMock, target: typePathDflt.With(&Type{Package: pkgTest}), expect: targetMockTest, }, - "path package match": { + "path-package-match": { loader: loaderMock, target: typePathDflt.With(&Type{Package: pkgMockTest}), expect: targetMockTest, }, - "path test": { + "path-test": { loader: loaderMock, target: typePathTest, expect: targetTestTest, }, - "path mock": { + "path-mock": { loader: loaderMock, target: typePathMock, expect: targetMockTest, }, - "path parent": { + "path-parent": { loader: loaderMock, target: typePathInternal, expect: targetInternalTest, }, - "path mock absolute": { + "path-mock-absolute": { loader: loaderMock, target: typePathMockAbs, expect: targetMockTest, }, - "path unknown absolute": { + "path-unknown-absolute": { loader: loaderMock, target: typePathUnknownAbs, expect: targetUnknownTest, }, - "path top absolute": { + "path-top-absolute": { loader: loaderMock, target: typePathTopAbs, expect: typePathTopAbs, @@ -207,12 +207,12 @@ type LoaderLoadParams struct { } var loaderLoadTestCases = map[string]LoaderLoadParams{ - "file loading": { + "file-loading": { loader: loaderMock, source: targetTest.With(typeFileDflt), expectLen: 1, }, - "failure loading": { + "failure-loading": { loader: loaderFail, source: targetTest.With(&Type{ File: filepath.Join(dirUp, dirMock, dirSubTest, fileIFace), @@ -244,7 +244,7 @@ type LoaderIFacesParams struct { } var loaderIFacesTestCases = map[string]LoaderIFacesParams{ - "file default": { + "file-default": { loader: loaderMock, source: targetTest.With(typeFileDflt), expectIFaces: []*IFace{{ @@ -252,7 +252,7 @@ var loaderIFacesTestCases = map[string]LoaderIFacesParams{ Methods: methodsLoadIFace, }}, }, - "file iface": { + "file-iface": { loader: loaderMock, source: targetTest.With(typeFileIFace), expectIFaces: []*IFace{{ @@ -260,20 +260,20 @@ var loaderIFacesTestCases = map[string]LoaderIFacesParams{ Methods: methodsLoadIFace, }}, }, - "file unknown": { + "file-unknown": { loader: loaderMock, source: targetTest.With(typeFileTestX), expectError: NewErrNotFound( targetTest.With(typeFileTestX), ""), }, - "file unknown with name": { + "file-unknown-with-name": { loader: loaderMock, source: targetTest.With(typeFileTestX).With(nameIFace), expectError: NewErrNotFound( targetTest.With(typeFileTestX), iface), }, - "name iface": { + "name-iface": { loader: loaderMock, source: targetTest.With(nameIFace), expectIFaces: []*IFace{{ @@ -281,7 +281,7 @@ var loaderIFacesTestCases = map[string]LoaderIFacesParams{ Methods: methodsLoadIFace, }}, }, - "name pattern": { + "name-pattern": { loader: loaderMock, source: targetTest.With(&Type{Name: MatchPatternDefault}), expectIFaces: []*IFace{{ @@ -289,7 +289,7 @@ var loaderIFacesTestCases = map[string]LoaderIFacesParams{ Methods: methodsLoadIFace, }}, }, - "name pattern failure": { + "name-pattern-failure": { loader: loaderMock, source: targetTest.With(&Type{Name: "**"}), expectError: NewErrMatcherInvalid( @@ -299,20 +299,20 @@ var loaderIFacesTestCases = map[string]LoaderIFacesParams{ Expr: "*", }), }, - "name struct": { + "name-struct": { loader: loaderMock, source: targetTest.With(&Type{Name: "Struct"}), expectError: NewErrNoIFace(targetTest. With(&Type{Name: "Struct"}), "Struct"), }, - "name missing": { + "name-missing": { loader: loaderMock, source: targetTest.With(&Type{Name: "Missing"}), expectError: NewErrNotFound(targetTest. With(&Type{Name: "Missing"}), "Missing"), }, - "failure loading": { + "failure-loading": { loader: loaderFail, source: targetTest.With(&Type{ File: filepath.Join(dirUp, dirMock, dirSubTest, fileIFace), diff --git a/internal/mock/models_test.go b/internal/mock/models_test.go index b4a7711..b93e91d 100644 --- a/internal/mock/models_test.go +++ b/internal/mock/models_test.go @@ -55,7 +55,7 @@ type NewFilesParams struct { } var newFilesTestCases = map[string]NewFilesParams{ - "target once": { + "target-once": { mocks: []*Mock{{Target: targetDefault}}, expectFiles: []*File{{ Target: targetDefault, @@ -63,7 +63,7 @@ var newFilesTestCases = map[string]NewFilesParams{ }}, }, - "target twice": { + "target-twice": { mocks: []*Mock{ {Target: targetDefault}, {Target: targetDefault}, }, @@ -75,7 +75,7 @@ var newFilesTestCases = map[string]NewFilesParams{ }}, }, - "target other name (ignored)": { + "target-other-name-(ignored)": { mocks: []*Mock{ {Target: targetDefault}, {Target: targetOtherName}, }, @@ -87,7 +87,7 @@ var newFilesTestCases = map[string]NewFilesParams{ }}, }, - "target other package": { + "target-other-package": { mocks: []*Mock{ {Target: targetDefault}, {Target: targetOtherPkg}, }, @@ -100,7 +100,7 @@ var newFilesTestCases = map[string]NewFilesParams{ }}, }, - "target other file": { + "target-other-file": { mocks: []*Mock{ {Target: targetDefault}, {Target: targetOtherFile}, }, @@ -113,7 +113,7 @@ var newFilesTestCases = map[string]NewFilesParams{ }}, }, - "target other path": { + "target-other-path": { mocks: []*Mock{ {Target: targetDefault}, {Target: targetOtherPath}, }, @@ -168,7 +168,7 @@ type FileParams struct { } var fileTestCases = map[string]FileParams{ - "file stdout": { + "file-stdout": { file: fileStdout, mocks: []*Mock{{ Source: sourceIFaceAny, @@ -177,7 +177,7 @@ var fileTestCases = map[string]FileParams{ expectName: os.Stdout.Name(), }, - "file custom": { + "file-custom": { file: fileCustom, mocks: []*Mock{{ Source: sourceIFaceAny, @@ -186,7 +186,7 @@ var fileTestCases = map[string]FileParams{ expectName: filepath.Join(testDirModels, fileMock), }, - "file error": { + "file-error": { file: fileStdout, mocks: []*Mock{{ Source: sourceIFaceAny, @@ -197,7 +197,7 @@ var fileTestCases = map[string]FileParams{ expectWrite: NewErrFileWriting(fileStdout, assert.AnError), }, - "no such directory": { + "no-such-directory": { file: fileNoTarget, mocks: []*Mock{{ Source: sourceIFaceAny, diff --git a/internal/mock/parser_test.go b/internal/mock/parser_test.go index 028a670..a8645af 100644 --- a/internal/mock/parser_test.go +++ b/internal/mock/parser_test.go @@ -26,7 +26,7 @@ type ParseParams struct { } var parseTestCases = map[string]ParseParams{ - "no argument": { + "no-argument": { loader: loaderTest, args: []string{}, expectMocks: []*Mock{{ @@ -35,19 +35,19 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "invalid argument flag": { + "invalid-argument-flag": { loader: loaderTest, args: []string{"--test"}, expectError: []error{NewErrArgInvalid(0, "--test")}, }, - "invalid argument unknown": { + "invalid-argument-unknown": { loader: loaderTest, args: []string{"--unknown=any"}, expectError: []error{NewErrArgInvalid(0, "--unknown=any")}, }, // TODO: add test case for invalid argument for guessed type not found. - "default file": { + "default-file": { loader: loaderTest, args: []string{}, target: typeFileMock, @@ -57,7 +57,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "default path": { + "default-path": { loader: loaderTest, args: []string{}, target: &Type{Path: pathTesting}, @@ -67,7 +67,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "default package": { + "default-package": { loader: loaderTest, args: []string{}, target: &Type{Package: pkgTest}, @@ -77,7 +77,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "default interface (ignore)": { + "default-interface-(ignore)": { loader: loaderTest, args: []string{}, target: &Type{Name: ifaceMock}, @@ -88,7 +88,7 @@ var parseTestCases = map[string]ParseParams{ }}, }, - "source package explicit": { + "source-package-explicit": { loader: loaderTest, args: []string{"--source-pkg=" + pkgTest}, expectMocks: []*Mock{{ @@ -97,7 +97,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source package derived": { + "source-package-derived": { loader: loaderTest, args: []string{"--source=" + pkgTest}, expectMocks: []*Mock{{ @@ -106,7 +106,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source package invalid": { + "source-package-invalid": { loader: NewLoader(DirDefault), // ensure path is not preload. args: []string{pathUnknown}, expectError: []error{ @@ -121,7 +121,7 @@ var parseTestCases = map[string]ParseParams{ }, }, - "source path explicit": { + "source-path-explicit": { loader: loaderTest, args: []string{"--source-path=" + pathTest}, expectMocks: []*Mock{{ @@ -130,7 +130,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source path derived": { + "source-path-derived": { loader: loaderTest, args: []string{"--source=" + pathTest}, expectMocks: []*Mock{{ @@ -139,7 +139,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source path guessed": { + "source-path-guessed": { loader: loaderRoot, args: []string{pathTest}, expectMocks: []*Mock{{ @@ -148,7 +148,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source path default": { + "source-path-default": { loader: loaderTest, args: []string{DirDefault}, expectMocks: []*Mock{{ @@ -157,7 +157,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source path invalid": { + "source-path-invalid": { // Ensure absolute path is pre-loaded for error message. loader: loaderMock.PreLoad(absUnknown), args: []string{pathUnknown}, @@ -172,7 +172,7 @@ var parseTestCases = map[string]ParseParams{ }, }, - "source file explicit": { + "source-file-explicit": { loader: loaderRoot, args: []string{"--source-file=" + dirSubTest + "/" + fileIFace}, expectMocks: []*Mock{{ @@ -181,7 +181,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source file derived": { + "source-file-derived": { loader: loaderRoot, args: []string{"--source=" + dirSubTest + "/" + fileIFace}, expectMocks: []*Mock{{ @@ -190,7 +190,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source file derived missing": { + "source-file-derived-missing": { loader: loaderRoot, args: []string{ "--source=" + fileUnknown, @@ -200,7 +200,7 @@ var parseTestCases = map[string]ParseParams{ }, expectMocks: nil, }, - "source file guessed": { + "source-file-guessed": { loader: loaderRoot, args: []string{dirSubTest + "/" + fileIFace}, expectMocks: []*Mock{{ @@ -209,7 +209,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source file guessed invalid": { + "source-file-guessed-invalid": { loader: loaderRoot, args: []string{fileUnknown}, expectError: []error{ @@ -224,7 +224,7 @@ var parseTestCases = map[string]ParseParams{ }, }, - "source directory explicit": { + "source-directory-explicit": { loader: loaderRoot, args: []string{"--source-file=" + dirSubTest}, expectMocks: []*Mock{{ @@ -233,7 +233,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source directory derived": { + "source-directory-derived": { loader: loaderRoot, args: []string{"--source=" + dirSubTest}, expectMocks: []*Mock{{ @@ -242,7 +242,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source directory guessed": { + "source-directory-guessed": { loader: loaderRoot, args: []string{dirSubTest}, expectMocks: []*Mock{{ @@ -251,7 +251,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "source directory invalid": { + "source-directory-invalid": { loader: loaderRoot, args: []string{dirUnknown}, expectError: []error{ @@ -265,7 +265,7 @@ var parseTestCases = map[string]ParseParams{ }, }, - "target package explicit": { + "target-package-explicit": { loader: loaderTest, args: []string{"--target-pkg=" + pkgTest}, expectMocks: []*Mock{{ @@ -274,7 +274,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "target package derived": { + "target-package-derived": { loader: loaderTest, args: []string{"--target=" + pkgTest}, expectMocks: []*Mock{{ @@ -283,7 +283,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "target package guessed": { + "target-package-guessed": { loader: loaderTest, args: []string{pkgTest}, expectMocks: []*Mock{{ @@ -293,7 +293,7 @@ var parseTestCases = map[string]ParseParams{ }}, }, - "target path explicit": { + "target-path-explicit": { loader: loaderTest, args: []string{"--target-path=" + pathMock}, expectMocks: []*Mock{{ @@ -302,7 +302,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "target path derived": { + "target-path-derived": { loader: loaderTest, args: []string{"--target=" + pathMock}, expectMocks: []*Mock{{ @@ -312,7 +312,7 @@ var parseTestCases = map[string]ParseParams{ }}, }, - "target file explicit": { + "target-file-explicit": { loader: loaderTest, args: []string{"--target-file=" + fileMock}, expectMocks: []*Mock{{ @@ -321,7 +321,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "target file derived": { + "target-file-derived": { loader: loaderTest, args: []string{"--target=" + typeFileTemp.File}, expectMocks: []*Mock{{ @@ -330,7 +330,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "target file derived missing": { + "target-file-derived-missing": { loader: loaderTest, args: []string{"--target=" + fileMock}, expectMocks: []*Mock{{ @@ -339,7 +339,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "target file guessed": { + "target-file-guessed": { loader: loaderTest, args: []string{fileMock}, expectMocks: []*Mock{{ @@ -348,7 +348,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "target file with path guessed": { + "target-file-with-path-guessed": { loader: loaderTest, args: []string{filepath.Join(dirUp, fileMock)}, expectMocks: []*Mock{{ @@ -360,7 +360,7 @@ var parseTestCases = map[string]ParseParams{ }}, }, - "target file with package guessed": { + "target-file-with-package-guessed": { loader: loaderTest, args: []string{fileMock, pkgTest}, expectMocks: []*Mock{{ @@ -370,7 +370,7 @@ var parseTestCases = map[string]ParseParams{ }}, }, - "iface explicit": { + "iface-explicit": { loader: loaderTest, args: []string{"--iface=" + iface}, expectMocks: []*Mock{{ @@ -379,7 +379,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "iface guessed": { + "iface-guessed": { loader: loaderTest, args: []string{iface}, expectMocks: []*Mock{{ @@ -388,7 +388,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "iface guessed with mock": { + "iface-guessed-with-mock": { loader: loaderTest, args: []string{ifaceArg}, expectMocks: []*Mock{{ @@ -397,7 +397,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "iface guessed empty": { + "iface-guessed-empty": { loader: loaderTest, args: []string{iface + "="}, expectMocks: []*Mock{{ @@ -406,7 +406,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "iface guessed empty interface": { + "iface-guessed-empty-interface": { loader: loaderTest, args: []string{"=Test"}, expectMocks: []*Mock{{ @@ -415,7 +415,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "iface guessed empty mock": { + "iface-guessed-empty-mock": { loader: loaderTest, args: []string{iface + "="}, expectMocks: []*Mock{{ @@ -424,7 +424,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "iface guessed mock pattern": { + "iface-guessed-mock-pattern": { loader: loaderTest, args: []string{ "=" + MockPatternDefault, @@ -435,7 +435,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "iface guessed match pattern": { + "iface-guessed-match-pattern": { loader: loaderTest, args: []string{ MatchPatternDefault + "=", @@ -447,7 +447,7 @@ var parseTestCases = map[string]ParseParams{ }}, }, - "iface twice different": { + "iface-twice-different": { loader: loaderTest, args: []string{ifaceArg, iface}, expectMocks: []*Mock{{ @@ -460,7 +460,7 @@ var parseTestCases = map[string]ParseParams{ Methods: methodsLoadIFace, }}, }, - "iface multiple times": { + "iface-multiple-times": { loader: loaderTest, args: []string{ifaceArg, ifaceArg, ifaceArg}, expectMocks: []*Mock{{ @@ -470,7 +470,7 @@ var parseTestCases = map[string]ParseParams{ }}, }, - "iface failure parsing regexp": { + "iface-failure-parsing-regexp": { loader: loaderTest, args: []string{ "--iface=**", @@ -484,7 +484,7 @@ var parseTestCases = map[string]ParseParams{ })), }, }, - "iface missing": { + "iface-missing": { loader: loaderTest, args: []string{"Missing", "Struct", iface}, expectError: []error{ @@ -495,7 +495,7 @@ var parseTestCases = map[string]ParseParams{ }, }, - "failure loading": { + "failure-loading": { loader: loaderFail, args: []string{ "--source-file=" + filepath.Join(dirUp, dirMock, dirSubTest, fileIFace), @@ -509,7 +509,7 @@ var parseTestCases = map[string]ParseParams{ } var parseAddTestCases = map[string]ParseParams{ - "package test": { + "package-test": { loader: loaderRoot, args: []string{ pathTesting, "Test", @@ -526,7 +526,7 @@ var parseAddTestCases = map[string]ParseParams{ }}, }, - "package test path": { + "package-test-path": { loader: loaderRoot, args: []string{ dirTest, "Test", @@ -543,7 +543,7 @@ var parseAddTestCases = map[string]ParseParams{ }}, }, - "package test file": { + "package-test-file": { loader: loaderRoot, args: []string{ dirTest + "/" + fileContext, "Test", @@ -560,7 +560,7 @@ var parseAddTestCases = map[string]ParseParams{ }}, }, - "package gomock": { + "package-gomock": { loader: loaderRoot, args: []string{pathGoMock, "TestReporter"}, expectMocks: []*Mock{{ @@ -570,7 +570,7 @@ var parseAddTestCases = map[string]ParseParams{ }}, }, - "package test and gomock": { + "package-test-and-gomock": { loader: loaderRoot, args: []string{ pkgMock, diff --git a/internal/mock/template_test.go b/internal/mock/template_test.go index 1f77b37..be9e885 100644 --- a/internal/mock/template_test.go +++ b/internal/mock/template_test.go @@ -26,14 +26,14 @@ type TemplateParams struct { } var templateTestCases = map[string]TemplateParams{ - "iface no methods": { + "iface-no-methods": { mocks: []*Mock{{ Source: sourceIFaceAny, Target: targetMockTestIFace.With(&Type{File: "-"}), }}, expect: expectIFaceStub, }, - "iface with methods": { + "iface-with-methods": { mocks: []*Mock{{ Source: sourceIFaceAny, Target: targetMockTestIFace.With(&Type{File: "-"}), diff --git a/internal/reflect/random_test.go b/internal/reflect/random_test.go index 36aa7e0..ecdbc91 100644 --- a/internal/reflect/random_test.go +++ b/internal/reflect/random_test.go @@ -126,14 +126,14 @@ type RandomParams struct { } var randomTestCases = map[string]RandomParams{ - "nil value": { + "nil-value": { value: nil, expect: test.Success, check: func(t test.Test, value any) { assert.Nil(t, value) }, }, - "nil pointer": { + "nil-pointer": { value: (*Simple)(nil), expect: test.Success, check: check, @@ -223,32 +223,32 @@ var randomTestCases = map[string]RandomParams{ expect: test.Success, check: check, }, - "slice int": { + "slice-int": { value: []int{}, expect: test.Success, check: check, }, - "slice string": { + "slice-string": { value: []string{}, expect: test.Success, check: check, }, - "map string-int": { + "map-string-int": { value: map[string]int{}, expect: test.Success, check: check, }, - "struct value": { + "struct-value": { value: Simple{}, expect: test.Success, check: check, }, - "struct simple": { + "struct-simple": { value: &Simple{}, expect: test.Success, check: check, }, - "struct complex": { + "struct-complex": { value: &struct { Ints []int Names []string @@ -257,17 +257,17 @@ var randomTestCases = map[string]RandomParams{ expect: test.Success, check: check, }, - "struct nested": { + "struct-nested": { value: &Complex{}, expect: test.Success, check: check, }, - "type channel": { + "type-channel": { value: make(chan int), expect: test.Success, check: check, }, - "type func": { + "type-func": { value: func() {}, expect: test.Success, check: check, diff --git a/mock/matcher_test.go b/mock/matcher_test.go index e178afa..b171871 100644 --- a/mock/matcher_test.go +++ b/mock/matcher_test.go @@ -45,55 +45,55 @@ type DiffParams struct { var diffTestCases = map[string]DiffParams{ // Nil cases. - "nil want": { + "nil-want": { want: nil, got: "something", }, - "nil got": { + "nil-got": { want: "something", got: nil, }, - "both nil": { + "both-nil": { want: nil, got: nil, }, // Different type cases. - "different types string vs int": { + "different-types-string-vs-int": { want: "hello", got: 42, }, - "different types struct vs map": { + "different-types-struct-vs-map": { want: struct{ A int }{1}, got: map[string]int{"a": 1}, }, // Unsupported type cases. - "int type": { + "int-type": { want: 42, got: 43, }, - "float type": { + "float-type": { want: 3.14, got: 2.71, }, - "bool type": { + "bool-type": { want: true, got: false, }, // String type cases. - "string equal": { + "string-equal": { want: "hello", got: "hello", }, - "string different": { + "string-different": { want: "hello", got: "world", diff: diff("1 +1", "-hello\n"+"+world\n"), }, - "string multiline": { + "string-multiline": { want: "line1\nline2\nline3", got: "line1\nmodified\nline3", diff: diff("1,3 +1,3", @@ -104,11 +104,11 @@ var diffTestCases = map[string]DiffParams{ }, // Struct type cases. - "struct equal": { + "struct-equal": { want: struct{ A int }{1}, got: struct{ A int }{1}, }, - "struct different": { + "struct-different": { want: struct{ A int }{1}, got: struct{ A int }{2}, diff: diff("1,4 +1,4", @@ -117,7 +117,7 @@ var diffTestCases = map[string]DiffParams{ "+ A: (int) 2\n"+ " }\n \n"), }, - "struct complex": { + "struct-complex": { want: struct { Name string Age int @@ -136,11 +136,11 @@ var diffTestCases = map[string]DiffParams{ }, // Map type cases. - "map equal": { + "map-equal": { want: map[string]int{"a": 1}, got: map[string]int{"a": 1}, }, - "map different values": { + "map-different-values": { want: map[string]int{"a": 1, "b": 2}, got: map[string]int{"a": 1, "b": 3}, diff: diff("1,5 +1,5", @@ -150,7 +150,7 @@ var diffTestCases = map[string]DiffParams{ "+ (string) (len=1) \"b\": (int) 3\n"+ " }\n \n"), }, - "map different keys": { + "map-different-keys": { want: map[string]int{"a": 1}, got: map[string]int{"b": 1}, diff: diff("1,4 +1,4", @@ -161,11 +161,11 @@ var diffTestCases = map[string]DiffParams{ }, // Slice type cases. - "slice equal": { + "slice-equal": { want: []int{1, 2, 3}, got: []int{1, 2, 3}, }, - "slice different": { + "slice-different": { want: []int{1, 2, 3}, got: []int{1, 4, 3}, diff: diff("1,6 +1,6", @@ -176,7 +176,7 @@ var diffTestCases = map[string]DiffParams{ " (int) 3\n"+ " }\n \n"), }, - "slice different length": { + "slice-different-length": { want: []int{1, 2, 3}, got: []int{1, 2}, diff: diff("1,6 +1,5", @@ -188,7 +188,7 @@ var diffTestCases = map[string]DiffParams{ "+ (int) 2\n"+ " }\n \n"), }, - "slice of strings": { + "slice-of-strings": { want: []string{"a", "b", "c"}, got: []string{"a", "x", "c"}, diff: diff("1,6 +1,6", @@ -201,11 +201,11 @@ var diffTestCases = map[string]DiffParams{ }, // Array type cases. - "array equal": { + "array-equal": { want: [3]int{1, 2, 3}, got: [3]int{1, 2, 3}, }, - "array different": { + "array-different": { want: [3]int{1, 2, 3}, got: [3]int{1, 4, 3}, diff: diff("1,6 +1,6", @@ -218,7 +218,7 @@ var diffTestCases = map[string]DiffParams{ }, // Pointer to supported type cases. - "pointer to struct": { + "pointer-to-struct": { want: &struct{ A int }{1}, got: &struct{ A int }{2}, diff: diff("1,4 +1,4", @@ -229,11 +229,11 @@ var diffTestCases = map[string]DiffParams{ }, // Time type cases. - "time equal": { + "time-equal": { want: time.Date(2025, 10, 27, 12, 0, 0, 0, time.UTC), got: time.Date(2025, 10, 27, 12, 0, 0, 0, time.UTC), }, - "time different": { + "time-different": { want: time.Date(2025, 10, 27, 12, 0, 0, 0, time.UTC), got: time.Date(2025, 10, 28, 12, 0, 0, 0, time.UTC), diff: diff("1,2 +1,2", @@ -264,7 +264,7 @@ type ConfigParams struct { var configTestCases = map[string]ConfigParams{ // Diff config options. - "diff context": { + "diff-context": { config: mock.Context(7), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -272,7 +272,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: 7, }, - "diff from-file": { + "diff-from-file": { config: mock.FromFile("expect"), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -280,7 +280,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: "expect", }, - "diff from-date": { + "diff-from-date": { config: mock.FromDate("2025-10-27"), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -288,7 +288,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: "2025-10-27", }, - "diff to-file": { + "diff-to-file": { config: mock.ToFile("actual.txt"), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -296,7 +296,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: "actual.txt", }, - "diff to-date": { + "diff-to-date": { config: mock.ToDate("2025-10-28"), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -306,7 +306,7 @@ var configTestCases = map[string]ConfigParams{ }, // Spew config options. - "spew indent": { + "spew-indent": { config: mock.Indent("\t"), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -314,7 +314,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: "\t", }, - "spew max-depth": { + "spew-max-depth": { config: mock.MaxDepth(5), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -322,7 +322,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: 5, }, - "spew disable-methods": { + "spew-disable-methods": { config: mock.DisableMethods(false), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -330,7 +330,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: false, }, - "spew disable-pointer-methods": { + "spew-disable-pointer-methods": { config: mock.DisablePointerMethods(true), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -338,7 +338,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: true, }, - "spew disable-pointer-addresses": { + "spew-disable-pointer-addresses": { config: mock.DisablePointerAddresses(false), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -346,7 +346,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: false, }, - "spew disable-capacities": { + "spew-disable-capacities": { config: mock.DisableCapacities(false), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -354,7 +354,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: false, }, - "spew continue-on-method": { + "spew-continue-on-method": { config: mock.ContinueOnMethod(true), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -362,7 +362,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: true, }, - "spew sort-keys": { + "spew-sort-keys": { config: mock.SortKeys(false), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -370,7 +370,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: false, }, - "spew spew-keys": { + "spew-spew-keys": { config: mock.SpewKeys(true), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -380,7 +380,7 @@ var configTestCases = map[string]ConfigParams{ }, // Spew config options. - "spew-time indent": { + "spew-time-indent": { config: mock.Indent("\t"), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -388,7 +388,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: "\t", }, - "spew-time max-depth": { + "spew-time-max-depth": { config: mock.MaxDepth(5), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -396,7 +396,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: 5, }, - "spew-time disable-methods": { + "spew-time-disable-methods": { config: mock.DisableMethods(false), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -404,7 +404,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: true, // exception: default is true for spewtime. }, - "spew-time disable-pointer-methods": { + "spew-time-disable-pointer-methods": { config: mock.DisablePointerMethods(true), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -412,7 +412,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: true, }, - "spew-time disable-pointer-addresses": { + "spew-time-disable-pointer-addresses": { config: mock.DisablePointerAddresses(false), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -420,7 +420,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: false, }, - "spew-time disable-capacities": { + "spew-time-disable-capacities": { config: mock.DisableCapacities(false), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -428,7 +428,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: false, }, - "spew-time continue-on-method": { + "spew-time-continue-on-method": { config: mock.ContinueOnMethod(true), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -436,7 +436,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: true, }, - "spew-time sort-keys": { + "spew-time-sort-keys": { config: mock.SortKeys(false), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -444,7 +444,7 @@ var configTestCases = map[string]ConfigParams{ }, expect: false, }, - "spew-time spew-keys": { + "spew-time-spew-keys": { config: mock.SpewKeys(true), access: func(mocks *mock.Mocks) any { return GetDiffConfigAccessor(mocks). @@ -476,42 +476,42 @@ type EqualMatchesParams struct { } var equalMatchesTestCases = map[string]EqualMatchesParams{ - "equal primitives": { + "equal-primitives": { want: 42, got: 42, expect: true, }, - "different primitives": { + "different-primitives": { want: 42, got: 43, expect: false, }, - "equal strings": { + "equal-strings": { want: "hello", got: "hello", expect: true, }, - "different strings": { + "different-strings": { want: "hello", got: "world", expect: false, }, - "equal structs": { + "equal-structs": { want: struct{ A int }{1}, got: struct{ A int }{1}, expect: true, }, - "different structs": { + "different-structs": { want: struct{ A int }{1}, got: struct{ A int }{2}, expect: false, }, - "equal slices": { + "equal-slices": { want: []int{1, 2, 3}, got: []int{1, 2, 3}, expect: true, }, - "different slices": { + "different-slices": { want: []int{1, 2, 3}, got: []int{1, 4, 3}, expect: false, @@ -587,18 +587,18 @@ type EqualStringParams struct { } var equalStringTestCases = map[string]EqualStringParams{ - "without diff": { + "without-diff": { want: "hello", got: nil, // Don't call Matches, so no diff expect: "string(\"hello\")", }, - "with diff": { + "with-diff": { want: "hello", got: "world", expect: "string(\"hello\")\nDiff (-want, +got):\n" + diff("1 +1", "-hello\n+world\n"), }, - "with long value": { + "with-long-value": { want: longValue, got: nil, // Don't call Matches, so no diff. expect: "string(\"" + diff --git a/mock/mocks_test.go b/mock/mocks_test.go index 226f054..7979d1d 100644 --- a/mock/mocks_test.go +++ b/mock/mocks_test.go @@ -72,7 +72,7 @@ type mockParams struct { } var mockTestCases = map[string]mockParams{ - "single mock with single call": { + "single-mock-with-single-call": { setup: mock.Setup( CallA("ok"), ), @@ -80,7 +80,7 @@ var mockTestCases = map[string]mockParams{ mock.Get(mocks, NewMockIFace).CallA("ok") }, }, - "single mock with two calls": { + "single-mock-with-two-calls": { setup: mock.Setup( CallA("ok"), CallA("okay"), ), @@ -89,7 +89,7 @@ var mockTestCases = map[string]mockParams{ mock.Get(mocks, NewMockIFace).CallA("okay") }, }, - "single mock with missing calls": { + "single-mock-with-missing-calls": { setup: mock.Setup( CallA("ok"), CallA("okay"), ), @@ -98,14 +98,14 @@ var mockTestCases = map[string]mockParams{ mock.Get(mocks, NewMockIFace).CallA("ok") }, }, - "single mock with unexpected call": { + "single-mock-with-unexpected-call": { misses: test.UnexpectedCall(NewMockIFace, "CallA", path.Join(SourceDir, "mocks_test.go:105"), "ok"), call: func(_ test.Test, mocks *mock.Mocks) { mock.Get(mocks, NewMockIFace).CallA("ok") }, }, - "single mock with more than expected calls": { + "single-mock-with-more-than-expected-calls": { setup: mock.Setup( CallA("ok"), ), @@ -118,7 +118,7 @@ var mockTestCases = map[string]mockParams{ }, }, - "single mock with many calls": { + "single-mock-with-many-calls": { setup: mock.Setup( CallA("okay"), CallB("okay", "okay"), @@ -128,7 +128,7 @@ var mockTestCases = map[string]mockParams{ mock.Get(mocks, NewMockIFace).CallB("okay") }, }, - "multiple mocks with many calls": { + "multiple-mocks-with-many-calls": { setup: mock.Setup( CallA("okay"), CallB("okay", "okay"), @@ -989,7 +989,7 @@ type WaitParams struct { } var waitTestCases = map[string]WaitParams{ - "simple wait": { + "simple-wait": { expect: test.Success, }, } diff --git a/reflect/reflect_test.go b/reflect/reflect_test.go index f07cd1d..5879327 100644 --- a/reflect/reflect_test.go +++ b/reflect/reflect_test.go @@ -35,7 +35,7 @@ type BuilderStructParams struct { } var builderStructTestCases = map[string]BuilderStructParams{ - "struct get init": { + "struct-get-init": { target: structInit, check: func(t test.Test, b reflect.Builder[Struct]) { assert.Equal(t, "init", b.Get("s")) @@ -50,7 +50,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ }, }, - "struct get invalid": { + "struct-get-invalid": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Get("invalid") @@ -58,7 +58,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ expect: test.Panic("target field not found [invalid]"), }, - "struct set invalid": { + "struct-set-invalid": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("invalid", "set final") @@ -66,7 +66,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ expect: test.Panic("target field not found [invalid]"), }, - "struct set compatible": { + "struct-set-compatible": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", string([]byte("set final"))). @@ -80,7 +80,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ }, }, - "struct set non-compatible": { + "struct-set-non-compatible": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", []byte("set final")) @@ -88,7 +88,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ expect: test.Panic("value must be compatible [[]uint8 => string]"), }, - "struct set": { + "struct-set": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -102,7 +102,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ }, }, - "struct set nil": { + "struct-set-nil": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", "set any").Set("a", "set any"). @@ -116,7 +116,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ }, }, - "struct reset no pointer": { + "struct-reset-no-pointer": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -126,7 +126,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ "[reflect_test.Struct => *reflect_test.Struct]"), }, - "struct reset pointer": { + "struct-reset-pointer": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -140,7 +140,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ }, }, - "struct reset any nil": { + "struct-reset-any-nil": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -154,7 +154,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ }, }, - "struct reset struct nil": { + "struct-reset-struct-nil": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -168,7 +168,7 @@ var builderStructTestCases = map[string]BuilderStructParams{ }, }, - "struct reset any invalid": { + "struct-reset-any-invalid": { target: structInit, setup: func(b reflect.Builder[Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -205,7 +205,7 @@ type BuilderPtrStructParams struct { var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ // Test cases for nil interface pointer. - "nil any get": { + "nil-any-get": { target: nil, check: func(t test.Test, b reflect.Builder[*Struct]) { assert.Equal(t, "", b.Get("s")) @@ -220,7 +220,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil any get invalid": { + "nil-any-get-invalid": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Get("invalid") @@ -228,7 +228,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ expect: test.Panic("target field not found [invalid]"), }, - "nil any set invalid": { + "nil-any-set-invalid": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("invalid", "set final") @@ -236,7 +236,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ expect: test.Panic("target field not found [invalid]"), }, - "nil any set": { + "nil-any-set": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -250,7 +250,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil any set compatible": { + "nil-any-set-compatible": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("s", string([]byte("set final"))). @@ -264,7 +264,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil any set non-compatible": { + "nil-any-set-non-compatible": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("s", []byte("set final")) @@ -272,7 +272,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ expect: test.Panic("value must be compatible [[]uint8 => string]"), }, - "nil any reset": { + "nil-any-reset": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -286,7 +286,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil any reset nil": { + "nil-any-reset-nil": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("", (*Struct)(nil)) @@ -297,7 +297,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil any reset invalid": { + "nil-any-reset-invalid": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -307,7 +307,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ "[struct {} => *reflect_test.Struct]"), }, - "nil any reset nil invalid": { + "nil-any-reset-nil-invalid": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("", (*Struct)(nil)) @@ -317,7 +317,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, // Test cases for nil struct pointer. - "nil struct get": { + "nil-struct-get": { target: new(Struct), check: func(t test.Test, b reflect.Builder[*Struct]) { assert.Equal(t, "", b.Get("s")) @@ -332,7 +332,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil struct get invalid": { + "nil-struct-get-invalid": { target: new(Struct), setup: func(b reflect.Builder[*Struct]) { b.Get("invalid") @@ -340,7 +340,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ expect: test.Panic("target field not found [invalid]"), }, - "nil struct set invalid": { + "nil-struct-set-invalid": { target: new(Struct), setup: func(b reflect.Builder[*Struct]) { b.Set("invalid", "set final") @@ -348,7 +348,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ expect: test.Panic("target field not found [invalid]"), }, - "nil struct set": { + "nil-struct-set": { target: new(Struct), setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -362,7 +362,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil struct set compatible": { + "nil-struct-set-compatible": { target: new(Struct), setup: func(b reflect.Builder[*Struct]) { b.Set("s", string([]byte("set final"))). @@ -376,7 +376,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil struct set non-compatible": { + "nil-struct-set-non-compatible": { target: new(Struct), setup: func(b reflect.Builder[*Struct]) { b.Set("s", []byte("set final")) @@ -384,7 +384,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ expect: test.Panic("value must be compatible [[]uint8 => string]"), }, - "nil struct reset": { + "nil-struct-reset": { target: new(Struct), setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -398,7 +398,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "nil struct reset invalid": { + "nil-struct-reset-invalid": { target: nil, setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -409,7 +409,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, // Test cases for struct pointer instance. - "ptr get": { + "ptr-get": { target: NewPtrStruct("init", "init"), check: func(t test.Test, b reflect.Builder[*Struct]) { assert.Equal(t, "init", b.Get("s")) @@ -424,7 +424,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "ptr get invalid": { + "ptr-get-invalid": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[*Struct]) { b.Get("invalid") @@ -432,7 +432,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ expect: test.Panic("target field not found [invalid]"), }, - "ptr set": { + "ptr-set": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -446,7 +446,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "ptr set compatible": { + "ptr-set-compatible": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[*Struct]) { b.Set("s", string([]byte("set final"))). @@ -460,7 +460,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "ptr set non-compatible": { + "ptr-set-non-compatible": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[*Struct]) { b.Set("s", []byte("set final")) @@ -468,7 +468,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ expect: test.Panic("value must be compatible [[]uint8 => string]"), }, - "ptr reset": { + "ptr-reset": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -482,7 +482,7 @@ var builderPtrStructTestCases = map[string]BuilderPtrStructParams{ }, }, - "ptr reset invalid": { + "ptr-reset-invalid": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[*Struct]) { b.Set("s", "set first").Set("a", "set first"). @@ -519,13 +519,13 @@ type BuilderAnyParams struct { var builderAnyTestCases = map[string]BuilderAnyParams{ // Test cases for invalid types. - "invalid type nil": { + "invalid-type-nil": { target: nil, check: func(t test.Test, b reflect.Builder[any]) { assert.Nil(t, b) }, }, - "invalid type int": { + "invalid-type-int": { target: 1, check: func(t test.Test, b reflect.Builder[any]) { assert.Nil(t, b) @@ -533,7 +533,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, // Test cases for struct instance. - "struct get init": { + "struct-get-init": { target: structInit, check: func(t test.Test, b reflect.Builder[any]) { assert.Equal(t, "init", b.Get("s")) @@ -548,7 +548,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "struct get invalid": { + "struct-get-invalid": { target: structInit, setup: func(b reflect.Builder[any]) { b.Get("invalid") @@ -556,7 +556,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("target field not found [invalid]"), }, - "struct set invalid": { + "struct-set-invalid": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("invalid", "set final") @@ -564,7 +564,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("target field not found [invalid]"), }, - "struct set": { + "struct-set": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("s", "set first").Set("a", "set first"). @@ -578,7 +578,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "struct set compatible": { + "struct-set-compatible": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("s", string([]byte("set final"))). @@ -592,7 +592,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "struct set non-compatible": { + "struct-set-non-compatible": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("s", []byte("set final")) @@ -600,7 +600,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("value must be compatible [[]uint8 => string]"), }, - "struct reset pointer": { + "struct-reset-pointer": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("s", "set first").Set("a", "set first"). @@ -614,7 +614,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "struct reset no pointer": { + "struct-reset-no-pointer": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("s", "set first").Set("a", "set first"). @@ -624,7 +624,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ "[reflect_test.Struct => *reflect_test.Struct]"), }, - "struct reset invalid": { + "struct-reset-invalid": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("s", "set first").Set("a", "set first"). @@ -635,7 +635,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, // Test cases for struct pointer instance. - "ptr get": { + "ptr-get": { target: NewPtrStruct("init", "init"), check: func(t test.Test, b reflect.Builder[any]) { assert.Equal(t, "init", b.Get("s")) @@ -650,7 +650,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "ptr get invalid": { + "ptr-get-invalid": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[any]) { b.Get("invalid") @@ -658,7 +658,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("target field not found [invalid]"), }, - "ptr set invalid": { + "ptr-set-invalid": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[any]) { b.Set("invalid", "set final") @@ -666,7 +666,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("target field not found [invalid]"), }, - "ptr set": { + "ptr-set": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[any]) { b.Set("s", "set first").Set("a", "set first"). @@ -680,7 +680,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "ptr set compatible": { + "ptr-set-compatible": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[any]) { b.Set("s", string([]byte("set final"))). @@ -694,7 +694,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "ptr set non-compatible": { + "ptr-set-non-compatible": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("s", []byte("set final")) @@ -702,7 +702,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("value must be compatible [[]uint8 => string]"), }, - "ptr reset": { + "ptr-reset": { target: NewPtrStruct("init", "init"), setup: func(b reflect.Builder[any]) { b.Set("s", "set first").Set("a", "set first"). @@ -717,7 +717,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, // Test cases for nil struct pointer instance. - "nil get": { + "nil-get": { target: new(Struct), check: func(t test.Test, b reflect.Builder[any]) { assert.Equal(t, "", b.Get("s")) @@ -732,7 +732,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "nil get invalid": { + "nil-get-invalid": { target: new(Struct), setup: func(b reflect.Builder[any]) { b.Get("invalid") @@ -740,7 +740,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("target field not found [invalid]"), }, - "nil set invalid": { + "nil-set-invalid": { target: new(Struct), setup: func(b reflect.Builder[any]) { b.Set("invalid", "set final") @@ -748,7 +748,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("target field not found [invalid]"), }, - "nil set": { + "nil-set": { target: new(Struct), setup: func(b reflect.Builder[any]) { b.Set("s", "set first").Set("a", "set first"). @@ -762,7 +762,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "nil set compatible": { + "nil-set-compatible": { target: new(Struct), setup: func(b reflect.Builder[any]) { b.Set("s", string([]byte("set final"))). @@ -776,7 +776,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ }, }, - "nil set non-compatible": { + "nil-set-non-compatible": { target: structInit, setup: func(b reflect.Builder[any]) { b.Set("s", []byte("set final")) @@ -784,7 +784,7 @@ var builderAnyTestCases = map[string]BuilderAnyParams{ expect: test.Panic("value must be compatible [[]uint8 => string]"), }, - "nil reset": { + "nil-reset": { target: new(Struct), setup: func(b reflect.Builder[any]) { b.Set("s", "set first").Set("a", "set first"). @@ -997,50 +997,50 @@ var findTestCases = map[string]FindParams{ expect: true, }, - "struct match": { + "struct-match": { param: structInit, deflt: "default", names: []string{"s"}, expect: "init", }, - "struct invalid": { + "struct-invalid": { param: structInit, deflt: "default", names: []string{"invalid"}, expect: "default", }, - "struct any": { + "struct-any": { param: structInit, deflt: "default", names: []string{}, expect: "init", }, - "struct star": { + "struct-star": { param: structInit, deflt: "default", names: []string{"invalid", "*"}, expect: "init", }, - "ptr match": { + "ptr-match": { param: structPtrInit, deflt: "default", names: []string{"s"}, expect: "init", }, - "ptr invalid": { + "ptr-invalid": { param: structPtrInit, deflt: "default", names: []string{"invalid"}, expect: "default", }, - "ptr any": { + "ptr-any": { param: structPtrInit, deflt: "default", names: []string{}, expect: "init", }, - "ptr star": { + "ptr-star": { param: structPtrInit, deflt: "default", names: []string{"invalid", "*"}, @@ -1067,74 +1067,74 @@ type NameParams struct { var nameTestCases = map[string]NameParams{ // Empty names. - "empty name with primitive": { + "empty-name-with-primitive": { name: "", param: 42, }, - "empty name with string": { + "empty-name-with-string": { name: "", param: "test", expect: "test", }, // Provided names. - "provided name": { + "provided-name": { name: "custom name", param: struct{}{}, expect: "custom-name", }, - "provided name with spaces": { + "provided-name-with-spaces": { name: "test case name", param: struct{}{}, expect: "test-case-name", }, - "provided name with multiple spaces": { + "provided-name-with-multiple-spaces": { name: "test case name", param: struct{}{}, expect: "test--case--name", }, - "provided name already hyphenated": { + "provided-name-already-hyphenated": { name: "test-case-name", param: struct{}{}, expect: "test-case-name", }, - "provided name overrides param": { + "provided-name-overrides-param": { name: "override", param: struct{ name string }{name: "ignored"}, expect: "override", }, // Parameter-based names. - "empty name with private name field": { + "empty-name-with-private-name-field": { name: "", param: struct{ name string }{name: "test case"}, expect: "test-case", }, - "empty name with exported name field": { + "empty-name-with-exported-name-field": { name: "", param: struct{ Name string }{Name: "test case"}, expect: "test-case", }, - "empty name without name field": { + "empty-name-without-name-field": { name: "", param: struct{ value string }{value: "test"}, }, - "empty name with empty name field": { + "empty-name-with-empty-name-field": { name: "", param: struct{ name string }{name: ""}, }, - "empty name with nil pointer": { + "empty-name-with-nil-pointer": { name: "", param: (*struct{ name string })(nil), }, // Special parameter-based cases. - "pointer to struct with name field": { + "pointer-to-struct-with-name-field": { name: "", param: &struct{ name string }{name: "pointer test"}, expect: "pointer-test", }, - "private and public name fields": { + "private-and-public-name-fields": { name: "", param: struct { name string diff --git a/test/common_test.go b/test/common_test.go index 3db4225..f4eeeda 100644 --- a/test/common_test.go +++ b/test/common_test.go @@ -171,175 +171,175 @@ var ( // context as well as the test runner. var commonTestCases = TestParamMap{ "": {}, - "base nothing": { + "base-nothing": { test: TestEmpty, expect: test.Success, }, - "base skip": { + "base-skip": { test: TestSkip, expect: test.Success, }, - "base skipf": { + "base-skipf": { test: TestSkipf, expect: test.Success, }, - "base skipnow": { + "base-skipnow": { test: TestSkipNow, expect: test.Success, }, - "base log": { + "base-log": { test: TestLog, expect: test.Success, }, - "base logf": { + "base-logf": { test: TestLogf, expect: test.Success, }, - "base error": { + "base-error": { test: TestError, expect: test.Failure, }, - "base errorf": { + "base-errorf": { test: TestErrorf, expect: test.Failure, }, - "base fatal": { + "base-fatal": { test: TestFatal, expect: test.Failure, consumed: true, }, - "base fatalf": { + "base-fatalf": { test: TestFatalf, expect: test.Failure, consumed: true, }, - "base fail": { + "base-fail": { test: TestFail, expect: test.Failure, consumed: true, }, - "base failnow": { + "base-failnow": { test: TestFailNow, expect: test.Failure, consumed: true, }, - "base panic": { + "base-panic": { test: TestPanic, expect: test.Failure, consumed: true, }, - "inrun success": { + "inrun-success": { test: test.InRun(test.Success, TestEmpty), expect: test.Success, }, - "inrun success with skip": { + "inrun-success-with-skip": { test: test.InRun(test.Success, TestSkip), expect: test.Success, }, - "inrun success with skipf": { + "inrun-success-with-skipf": { test: test.InRun(test.Success, TestSkipf), expect: test.Success, }, - "inrun success with skipnow": { + "inrun-success-with-skipnow": { test: test.InRun(test.Success, TestSkipNow), expect: test.Success, }, - "inrun success with log": { + "inrun-success-with-log": { test: test.InRun(test.Success, TestLog), expect: test.Success, }, - "inrun success with logf": { + "inrun-success-with-logf": { test: test.InRun(test.Success, TestLogf), expect: test.Success, }, - "inrun success with error": { + "inrun-success-with-error": { test: test.InRun(test.Success, TestError), expect: test.Failure, }, - "inrun success with errorf": { + "inrun-success-with-errorf": { test: test.InRun(test.Success, TestErrorf), expect: test.Failure, }, - "inrun success with fatal": { + "inrun-success-with-fatal": { test: test.InRun(test.Success, TestFatal), expect: test.Failure, consumed: true, }, - "inrun success with fatalf": { + "inrun-success-with-fatalf": { test: test.InRun(test.Success, TestFatalf), expect: test.Failure, consumed: true, }, - "inrun success with fail": { + "inrun-success-with-fail": { test: test.InRun(test.Success, TestFail), expect: test.Failure, consumed: true, }, - "inrun success with failnow": { + "inrun-success-with-failnow": { test: test.InRun(test.Success, TestFailNow), expect: test.Failure, consumed: true, }, - "inrun success with panic": { + "inrun-success-with-panic": { test: test.InRun(test.Success, TestPanic), expect: test.Failure, consumed: true, }, - "inrun failure": { + "inrun-failure": { test: test.InRun(test.Failure, TestEmpty), expect: test.Failure, }, - "inrun failure with skip": { + "inrun-failure-with-skip": { test: test.InRun(test.Failure, TestSkip), expect: test.Failure, }, - "inrun failure with skipf": { + "inrun-failure-with-skipf": { test: test.InRun(test.Failure, TestSkipf), expect: test.Failure, }, - "inrun failure with skipnow": { + "inrun-failure-with-skipnow": { test: test.InRun(test.Failure, TestSkipNow), expect: test.Failure, }, - "inrun failure with log": { + "inrun-failure-with-log": { test: test.InRun(test.Failure, TestLog), expect: test.Failure, }, - "inrun failure with logf": { + "inrun-failure-with-logf": { test: test.InRun(test.Failure, TestLogf), expect: test.Failure, }, - "inrun failure with error": { + "inrun-failure-with-error": { test: test.InRun(test.Failure, TestError), expect: test.Success, }, - "inrun failure with errorf": { + "inrun-failure-with-errorf": { test: test.InRun(test.Failure, TestErrorf), expect: test.Success, }, - "inrun failure with fatal": { + "inrun-failure-with-fatal": { test: test.InRun(test.Failure, TestFatal), expect: test.Success, consumed: true, }, - "inrun failure with fatalf": { + "inrun-failure-with-fatalf": { test: test.InRun(test.Failure, TestFatalf), expect: test.Success, consumed: true, }, - "inrun failure with fail": { + "inrun-failure-with-fail": { test: test.InRun(test.Failure, TestFail), expect: test.Success, consumed: true, }, - "inrun failure with failnow": { + "inrun-failure-with-failnow": { test: test.InRun(test.Failure, TestFailNow), expect: test.Success, consumed: true, }, - "inrun failure with panic": { + "inrun-failure-with-panic": { test: test.InRun(test.Failure, TestPanic), expect: test.Success, consumed: true, diff --git a/test/context_test.go b/test/context_test.go index 0edefb5..a0c8e72 100644 --- a/test/context_test.go +++ b/test/context_test.go @@ -89,18 +89,18 @@ type CleanupParams struct { // cleanupTestCases is a map of test parameters for testing the Cleanup method. var cleanupTestCases = map[string]CleanupParams{ - "nil cleanup": { + "nil-cleanup": { test: func(t test.Test) { t.Cleanup(nil) }, }, - "single cleanup": { + "single-cleanup": { test: func(t test.Test) { t.Cleanup(func() { t.(*test.Context).Done() }) }, wait: 1, }, - "multiple cleanups": { + "multiple-cleanups": { test: func(t test.Test) { t.Cleanup(func() { t.(*test.Context).Done() }) t.Cleanup(func() { t.(*test.Context).Done() }) @@ -108,7 +108,7 @@ var cleanupTestCases = map[string]CleanupParams{ }, wait: 3, }, - "cleanup with nil mixed": { + "cleanup-with-nil-mixed": { test: func(t test.Test) { t.Cleanup(nil) t.Cleanup(func() { t.(*test.Context).Done() }) @@ -150,14 +150,14 @@ type ParallelParams struct { // parallelTestCases is a map of test parameters for testing the test context // in conflicting parallel cases resulting in a panics. var parallelTestCases = map[string]ParallelParams{ - "setenv in run without parallel": { + "setenv-in-run-without-parallel": { during: func(t test.Test) { t.Setenv("TESTING", "during") assert.Equal(t, "during", os.Getenv("TESTING")) }, }, - "setenv in run with parallel": { + "setenv-in-run-with-parallel": { setup: test.Panic("testing: test using t.Setenv or t.Chdir" + " can not use t.Parallel"), parallel: true, @@ -167,7 +167,7 @@ var parallelTestCases = map[string]ParallelParams{ }, }, - "setenv before run without parallel": { + "setenv-before-run-without-parallel": { before: func(t test.Test) { t.Setenv("TESTING", "before") assert.Equal(t, "before", os.Getenv("TESTING")) @@ -178,7 +178,7 @@ var parallelTestCases = map[string]ParallelParams{ }, }, - "setenv before run with parallel": { + "setenv-before-run-with-parallel": { setup: test.Panic("testing: test using t.Setenv or t.Chdir" + " can not use t.Parallel"), parallel: true, @@ -188,7 +188,7 @@ var parallelTestCases = map[string]ParallelParams{ }, }, - "swallow multiple parallel calls": { + "swallow-multiple-parallel-calls": { during: func(t test.Test) { t.Parallel() t.Parallel() diff --git a/test/pattern_test.go b/test/pattern_test.go index 130521c..7bc2570 100644 --- a/test/pattern_test.go +++ b/test/pattern_test.go @@ -36,13 +36,13 @@ type PtrParams struct { var ptrTestCases = map[string]PtrParams{ // Primitive types - "bool true": {value: true}, - "bool false": {value: false}, + "bool-true": {value: true}, + "bool-false": {value: false}, // Integer types "int": {value: 42}, - "int zero": {value: 0}, - "int negative": {value: -123}, + "int-zero": {value: 0}, + "int-negative": {value: -123}, "int8": {value: int8(127)}, "int16": {value: int16(32767)}, "int32": {value: int32(2147483647)}, @@ -59,9 +59,9 @@ var ptrTestCases = map[string]PtrParams{ // Floating point types "float32": {value: float32(3.14)}, - "float32 zero": {value: float32(0.0)}, + "float32-zero": {value: float32(0.0)}, "float64": {value: 3.141592653589793}, - "float64 negative": {value: -2.718281828}, + "float64-negative": {value: -2.718281828}, // Complex types "complex64": {value: complex64(1 + 2i)}, @@ -69,40 +69,40 @@ var ptrTestCases = map[string]PtrParams{ // String types "string": {value: "hello world"}, - "string empty": {value: ""}, - "string unicode": {value: "Hello, 🌍"}, + "string-empty": {value: ""}, + "string-unicode": {value: "Hello, 🌍"}, // Slice literals - "slice int": {value: []int{1, 2, 3}}, - "slice string": {value: []string{"a", "b", "c"}}, - "slice empty": {value: []int{}}, - "slice nil": {value: []int(nil)}, + "slice-int": {value: []int{1, 2, 3}}, + "slice-string": {value: []string{"a", "b", "c"}}, + "slice-empty": {value: []int{}}, + "slice-nil": {value: []int(nil)}, // Map literals - "map string int": {value: map[string]int{"one": 1, "two": 2}}, - "map empty": {value: map[string]int{}}, - "map nil": {value: map[string]int(nil)}, + "map-string-int": {value: map[string]int{"one": 1, "two": 2}}, + "map-empty": {value: map[string]int{}}, + "map-nil": {value: map[string]int(nil)}, // Struct literals "struct": {value: TestStruct{name: "test", id: 42}}, - "struct zero": {value: TestStruct{}}, - "struct anonymous": {value: struct{ X int }{X: 10}}, + "struct-zero": {value: TestStruct{}}, + "struct-anonymous": {value: struct{ X int }{X: 10}}, // Named types - "named slice": {value: TestSlice{"x", "y", "z"}}, - "named map": {value: TestMap{"foo": 1, "bar": 2}}, + "named-slice": {value: TestSlice{"x", "y", "z"}}, + "named-map": {value: TestMap{"foo": 1, "bar": 2}}, // Pointer types - "pointer to int": {value: test.Ptr(42)}, - "pointer to string": {value: test.Ptr("value")}, - "pointer to struct": {value: &TestStruct{name: "ptr", id: 99}}, + "pointer-to-int": {value: test.Ptr(42)}, + "pointer-to-string": {value: test.Ptr("value")}, + "pointer-to-struct": {value: &TestStruct{name: "ptr", id: 99}}, // Array literals - "array int": {value: [3]int{1, 2, 3}}, - "array string": {value: [2]string{"hello", "world"}}, + "array-int": {value: [3]int{1, 2, 3}}, + "array-string": {value: [2]string{"hello", "world"}}, // Interface types - "interface any": {value: any("interface value")}, + "interface-any": {value: any("interface value")}, } func TestPtr(t *testing.T) { @@ -142,11 +142,11 @@ var mustTestCases = map[string]MustParams{ arg: 3.14, expect: 3.14, }, - "bool true": { + "bool-true": { arg: true, expect: true, }, - "bool false": { + "bool-false": { arg: false, expect: false, }, @@ -170,27 +170,27 @@ var mustTestCases = map[string]MustParams{ arg: testFunc, expect: testFunc, }, - "named slice": { + "named-slice": { arg: TestSlice{"x", "y", "z"}, expect: TestSlice{"x", "y", "z"}, }, - "named map": { + "named-map": { arg: TestMap{"foo": 1, "bar": 2}, expect: TestMap{"foo": 1, "bar": 2}, }, - "zero value int": { + "zero-value-int": { arg: 0, expect: 0, }, - "zero value string": { + "zero-value-string": { arg: "", expect: "", }, - "empty slice": { + "empty-slice": { arg: []string{}, expect: []string{}, }, - "empty map": { + "empty-map": { arg: map[string]int{}, expect: map[string]int{}, }, @@ -199,7 +199,7 @@ var mustTestCases = map[string]MustParams{ err: assert.AnError, expect: nil, }, - "nil error with value": { + "nil-error-with-value": { arg: "success", err: nil, expect: "success", @@ -232,137 +232,137 @@ type CastParams struct { } var castTestCases = map[string]CastParams{ - "int to int": { + "int-to-int": { arg: 42, cast: func(arg any) any { return test.Cast[int](arg) }, expect: 42, }, - "string to string": { + "string-to-string": { arg: "value", cast: func(arg any) any { return test.Cast[string](arg) }, expect: "value", }, - "slice to slice string": { + "slice-to-slice-string": { arg: []string{"a", "b", "c"}, cast: func(arg any) any { return test.Cast[[]string](arg) }, expect: []string{"a", "b", "c"}, }, - "slice to slice names": { + "slice-to-slice-names": { arg: TestSlice{"x", "y", "z"}, cast: func(arg any) any { return test.Cast[TestSlice](arg) }, expect: TestSlice{"x", "y", "z"}, }, - "map to map": { + "map-to-map": { arg: TestMap{"foo": 1, "bar": 2}, cast: func(arg any) any { return test.Cast[TestMap](arg) }, expect: TestMap{"foo": 1, "bar": 2}, }, - "struct to struct": { + "struct-to-struct": { arg: TestStruct{name: "example", id: 123}, cast: func(arg any) any { return test.Cast[TestStruct](arg) }, expect: TestStruct{name: "example", id: 123}, }, - "pointer to pointer": { + "pointer-to-pointer": { arg: &TestStruct{name: "example", id: 123}, cast: func(arg any) any { return test.Cast[*TestStruct](arg) }, expect: &TestStruct{name: "example", id: 123}, }, - "function to function": { + "function-to-function": { arg: testFunc, cast: func(arg any) any { return test.Cast[TestFunc](arg) }, expect: testFunc, }, // Casts to any. - "int to any": { + "int-to-any": { arg: 123, cast: func(arg any) any { return test.Cast[any](arg) }, expect: 123, }, - "bool to any": { + "bool-to-any": { arg: true, cast: func(arg any) any { return test.Cast[any](arg) }, expect: true, }, - "string to any": { + "string-to-any": { arg: "hello", cast: func(arg any) any { return test.Cast[any](arg) }, expect: "hello", }, - "slice to any int": { + "slice-to-any-int": { arg: []int{1, 2, 3}, cast: func(arg any) any { return test.Cast[any](arg) }, expect: []int{1, 2, 3}, }, - "slice to any named": { + "slice-to-any-named": { arg: TestSlice{"a", "b", "c"}, cast: func(arg any) any { return test.Cast[any](arg) }, expect: TestSlice{"a", "b", "c"}, }, - "map to any": { + "map-to-any": { arg: TestMap{"key": 42, "other": 100}, cast: func(arg any) any { return test.Cast[any](arg) }, expect: TestMap{"key": 42, "other": 100}, }, - "struct to any": { + "struct-to-any": { arg: TestStruct{name: "test", id: 42}, cast: func(arg any) any { return test.Cast[any](arg) }, expect: TestStruct{name: "test", id: 42}, }, - "pointer to any": { + "pointer-to-any": { arg: &TestStruct{name: "pointer", id: 99}, cast: func(arg any) any { return test.Cast[any](arg) }, expect: &TestStruct{name: "pointer", id: 99}, }, - "function to any": { + "function-to-any": { arg: fmt.Sprintf, cast: func(arg any) any { return test.Cast[any](arg) }, expect: nil, // Special case - just test that cast succeeds }, // Panic cases - "nil to any": { + "nil-to-any": { setup: test.Panic(fmt.Sprintf("cast failed []: %v", nil)), arg: nil, cast: func(arg any) any { return test.Cast[any](arg) }, }, - "string to int": { + "string-to-int": { setup: test.Panic(fmt.Sprintf("cast failed [%v]: %v", reflect.TypeOf(0), "value")), arg: "value", cast: func(arg any) any { return test.Cast[int](arg) }, }, - "int to string": { + "int-to-string": { setup: test.Panic(fmt.Sprintf("cast failed [%v]: %v", reflect.TypeOf(""), 42)), arg: 42, cast: func(arg any) any { return test.Cast[string](arg) }, }, - "nil to string": { + "nil-to-string": { setup: test.Panic(fmt.Sprintf("cast failed [%v]: %v", reflect.TypeOf(""), nil)), arg: nil, cast: func(arg any) any { return test.Cast[string](arg) }, }, - "float to int": { + "float-to-int": { setup: test.Panic(fmt.Sprintf("cast failed [%v]: %v", reflect.TypeOf(0), 3.14)), arg: 3.14, cast: func(arg any) any { return test.Cast[int](arg) }, }, - "string to struct": { + "string-to-struct": { setup: test.Panic(fmt.Sprintf("cast failed [%v]: %v", reflect.TypeOf(TestStruct{}), "invalid")), arg: "invalid", cast: func(arg any) any { return test.Cast[TestStruct](arg) }, }, - "int to map": { + "int-to-map": { setup: test.Panic(fmt.Sprintf("cast failed [%v]: %v", reflect.TypeOf(TestMap{}), 42)), arg: 42, cast: func(arg any) any { return test.Cast[TestMap](arg) }, }, - "slice to named slice": { + "slice-to-named-slice": { setup: test.Panic(fmt.Sprintf("cast failed [%v]: %v", reflect.TypeOf(TestSlice{}), []string{"too", "many"})), arg: []string{"too", "many"}, @@ -402,29 +402,29 @@ type RecoverParams struct { var recoverTestCases = map[string]RecoverParams{ // Failure to panic. - "no panic with nil": {}, - "no panic with string": { + "no-panic-with-nil": {}, + "no-panic-with-string": { setup: "no panic", }, - "no panic with error": { + "no-panic-with-error": { setup: assert.AnError, }, - "no panic with pointer error": { + "no-panic-with-pointer-error": { setup: &assert.AnError, }, // Successful recovery. - "panic with string": { + "panic-with-string": { panic: "a panic occurred", setup: "a panic occurred", expect: test.Success, }, - "panic with error": { + "panic-with-error": { panic: assert.AnError, setup: assert.AnError, expect: test.Success, }, - "panic with same error pointer": { + "panic-with-same-error-pointer": { panic: &assert.AnError, setup: &assert.AnError, expect: test.Success, diff --git a/test/reporter_test.go b/test/reporter_test.go index e288f86..296775f 100644 --- a/test/reporter_test.go +++ b/test/reporter_test.go @@ -27,35 +27,35 @@ type MatcherParams struct { } var errorMatcherTestCases = map[string]MatcherParams{ - "success string-string": { + "success-string-string": { matcher: test.EqError, base: anErrorString, match: anErrorString, expectMatches: true, expectString: anErrorMessage + "(string)", }, - "success string-error": { + "success-string-error": { matcher: test.EqError, base: anErrorString, match: assert.AnError, expectMatches: true, expectString: anErrorMessage + "(string)", }, - "success error-string": { + "success-error-string": { matcher: test.EqError, base: assert.AnError, match: anErrorString, expectMatches: true, expectString: anErrorMessage + "(*errors.errorString)", }, - "success error-error": { + "success-error-error": { matcher: test.EqError, base: assert.AnError, match: assert.AnError, expectMatches: true, expectString: anErrorMessage + "(*errors.errorString)", }, - "success other-other": { + "success-other-other": { matcher: test.EqError, base: 1, match: 1, @@ -63,35 +63,35 @@ var errorMatcherTestCases = map[string]MatcherParams{ expectString: "is equal to 1 (int)", }, - "failure string-string": { + "failure-string-string": { matcher: test.EqError, base: assert.AnError, match: errOther, expectMatches: false, expectString: anErrorMessage + "(*errors.errorString)", }, - "failure string-error": { + "failure-string-error": { matcher: test.EqError, base: anErrorString, match: errOther, expectMatches: false, expectString: anErrorMessage + "(string)", }, - "failure error-string": { + "failure-error-string": { matcher: test.EqError, base: assert.AnError, match: otherError, expectMatches: false, expectString: anErrorMessage + "(*errors.errorString)", }, - "failure error-error": { + "failure-error-error": { matcher: test.EqError, base: assert.AnError, match: errOther, expectMatches: false, expectString: anErrorMessage + "(*errors.errorString)", }, - "failure other-other": { + "failure-other-other": { matcher: test.EqError, base: 1, match: false, @@ -165,7 +165,7 @@ type ReporterParams struct { } var reporterTestCases = map[string]ReporterParams{ - "log called": { + "log-called": { setup: test.Log("log message"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) @@ -173,7 +173,7 @@ var reporterTestCases = map[string]ReporterParams{ }, expect: test.Success, }, - "logf called": { + "logf-called": { setup: test.Logf("%s", "log message"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) @@ -181,49 +181,49 @@ var reporterTestCases = map[string]ReporterParams{ }, expect: test.Success, }, - "error called": { + "error-called": { setup: test.Error("fail"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) t.Error("fail") }, }, - "errorf called": { + "errorf-called": { setup: test.Errorf("%s", "fail"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) t.Errorf("%s", "fail") }, }, - "fatal called": { + "fatal-called": { setup: test.Fatal("fail"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) t.Fatal("fail") }, }, - "fatalf called": { + "fatalf-called": { setup: test.Fatalf("%s", "fail"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) t.Fatalf("%s", "fail") }, }, - "fail called": { + "fail-called": { setup: test.Fail(), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) t.Fail() }, }, - "failnow called": { + "failnow-called": { setup: test.FailNow(), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) t.FailNow() }, }, - "panic called": { + "panic-called": { setup: test.Panic("fail"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) @@ -231,14 +231,14 @@ var reporterTestCases = map[string]ReporterParams{ }, }, - "log undeclared": { + "log-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "Log", CallerLog, "log"), call: func(t test.Test) { t.Log("log") }, }, - "log undeclared twice": { + "log-undeclared-twice": { misses: test.UnexpectedCall(test.NewValidator, "Log", CallerLog, "log"), call: func(t test.Test) { @@ -246,14 +246,14 @@ var reporterTestCases = map[string]ReporterParams{ t.Log("log") }, }, - "logf undeclared": { + "logf-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "Logf", CallerLogf, "%s", "log"), call: func(t test.Test) { t.Logf("%s", "log") }, }, - "logf undeclared twice": { + "logf-undeclared-twice": { misses: test.UnexpectedCall(test.NewValidator, "Logf", CallerLogf, "%s", "log"), call: func(t test.Test) { @@ -261,14 +261,14 @@ var reporterTestCases = map[string]ReporterParams{ t.Logf("%s", "log") }, }, - "error undeclared": { + "error-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "Error", CallerError, "fail"), call: func(t test.Test) { t.Error("fail") }, }, - "error undeclared twice": { + "error-undeclared-twice": { misses: test.UnexpectedCall(test.NewValidator, "Error", CallerError, "fail"), call: func(t test.Test) { @@ -276,14 +276,14 @@ var reporterTestCases = map[string]ReporterParams{ t.Error("fail") }, }, - "errorf undeclared": { + "errorf-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "Errorf", CallerErrorf, "%s", "fail"), call: func(t test.Test) { t.Errorf("%s", "fail") }, }, - "errorf undeclared twice": { + "errorf-undeclared-twice": { misses: test.UnexpectedCall(test.NewValidator, "Errorf", CallerErrorf, "%s", "fail"), call: func(t test.Test) { @@ -291,14 +291,14 @@ var reporterTestCases = map[string]ReporterParams{ t.Errorf("%s", "fail") }, }, - "fatal undeclared": { + "fatal-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "Fatal", CallerFatal, "fail"), call: func(t test.Test) { t.Fatal("fail") }, }, - "fatal undeclared twice": { + "fatal-undeclared-twice": { misses: test.UnexpectedCall(test.NewValidator, "Fatal", CallerFatal, "fail"), call: func(t test.Test) { @@ -307,14 +307,14 @@ var reporterTestCases = map[string]ReporterParams{ t.Fatal("fail") }, }, - "fatalf undeclared": { + "fatalf-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "Fatalf", CallerFatalf, "%s", "fail"), call: func(t test.Test) { t.Fatalf("%s", "fail") }, }, - "fatalf undeclared twice": { + "fatalf-undeclared-twice": { misses: test.UnexpectedCall(test.NewValidator, "Fatalf", CallerFatalf, "%s", "fail"), call: func(t test.Test) { @@ -323,14 +323,14 @@ var reporterTestCases = map[string]ReporterParams{ t.Fatalf("%s", "fail") }, }, - "fail undeclared": { + "fail-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "Fail", CallerFail), call: func(t test.Test) { t.Fail() }, }, - "fail undeclared twice": { + "fail-undeclared-twice": { misses: test.UnexpectedCall(test.NewValidator, "Fail", CallerFail), call: func(t test.Test) { @@ -339,14 +339,14 @@ var reporterTestCases = map[string]ReporterParams{ t.Fail() }, }, - "failnow undeclared": { + "failnow-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "FailNow", CallerFailNow), call: func(t test.Test) { t.FailNow() }, }, - "failnow undeclared twice": { + "failnow-undeclared-twice": { misses: test.UnexpectedCall(test.NewValidator, "FailNow", CallerFailNow), call: func(t test.Test) { @@ -355,7 +355,7 @@ var reporterTestCases = map[string]ReporterParams{ t.FailNow() }, }, - "panic undeclared": { + "panic-undeclared": { misses: test.UnexpectedCall(test.NewValidator, "Panic", CallerPanic, "fail"), call: func(test.Test) { @@ -366,7 +366,7 @@ var reporterTestCases = map[string]ReporterParams{ // Only `Error`and `Errorf` can be consumed more than once, since `Fatal`, // `Fatalf`, `FailNow`, and panic will stop execution immediately. The // second call is effectively unreachable. - "error consumed": { + "error-consumed": { setup: test.Error("fail"), misses: test.ConsumedCall(test.NewValidator, "Error", CallerTestError, CallerReporterError, "fail"), @@ -376,7 +376,7 @@ var reporterTestCases = map[string]ReporterParams{ t.Error("fail") }, }, - "errorf consumed": { + "errorf-consumed": { setup: test.Errorf("%s", "fail"), misses: test.ConsumedCall(test.NewValidator, "Errorf", CallerTestErrorf, CallerReporterErrorf, "%s", "fail"), @@ -386,7 +386,7 @@ var reporterTestCases = map[string]ReporterParams{ t.Errorf("%s", "fail") }, }, - "fatal consumed": { + "fatal-consumed": { setup: test.Fatal("fail"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) @@ -395,7 +395,7 @@ var reporterTestCases = map[string]ReporterParams{ t.Fatal("fail") }, }, - "fatalf consumed": { + "fatalf-consumed": { setup: test.Fatalf("%s", "fail"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) @@ -404,7 +404,7 @@ var reporterTestCases = map[string]ReporterParams{ t.Fatalf("%s", "fail") }, }, - "fail consumed": { + "fail-consumed": { setup: test.Fail(), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) @@ -413,7 +413,7 @@ var reporterTestCases = map[string]ReporterParams{ t.Fail() }, }, - "failnow consumed": { + "failnow-consumed": { setup: test.FailNow(), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) @@ -422,7 +422,7 @@ var reporterTestCases = map[string]ReporterParams{ t.FailNow() }, }, - "panic consumed": { + "panic-consumed": { setup: test.Panic("fail"), call: func(t test.Test) { test.Cast[*test.Context](t).Expect(test.Success) @@ -435,14 +435,14 @@ var reporterTestCases = map[string]ReporterParams{ // The mock setup is automatically creating a [test.Validator] requiring // a the test environment to expect a failure to get called. To satisfy // this, we need to create at least one failure. - "errorf missing": { + "errorf-missing": { setup: mock.Chain(test.Errorf("%s", "fail"), test.Errorf("%s", "fail")), misses: test.MissingCalls(test.Errorf("%s", "fail")), call: func(t test.Test) { t.Errorf("%s", "fail") }, }, - "errorf missing two calls": { + "errorf-missing-two-calls": { setup: mock.Chain( test.Errorf("%s", "fail"), test.Errorf("%s", "fail"), test.Errorf("%s", "fail-x"), @@ -454,28 +454,28 @@ var reporterTestCases = map[string]ReporterParams{ t.Errorf("%s", "fail") }, }, - "fatalf missing": { + "fatalf-missing": { setup: mock.Chain(test.Errorf("%s", "fail"), test.Fatalf("%s", "fail")), misses: test.MissingCalls(test.Fatalf("%s", "fail")), call: func(t test.Test) { t.Errorf("%s", "fail") }, }, - "fail missing": { + "fail-missing": { setup: mock.Chain(test.Errorf("%s", "fail"), test.Fail()), misses: test.MissingCalls(test.Fail()), call: func(t test.Test) { t.Fail() }, }, - "failnow missing": { + "failnow-missing": { setup: mock.Chain(test.Errorf("%s", "fail"), test.FailNow()), misses: test.MissingCalls(test.FailNow()), call: func(t test.Test) { t.Errorf("%s", "fail") }, }, - "panic missing": { + "panic-missing": { setup: mock.Chain(test.Errorf("%s", "fail"), test.Panic("fail")), misses: test.MissingCalls(test.Panic("fail")), call: func(t test.Test) { diff --git a/test/runner_test.go b/test/runner_test.go index 11ca62b..663a921 100644 --- a/test/runner_test.go +++ b/test/runner_test.go @@ -28,7 +28,7 @@ func TestParamsRun(t *testing.T) { // TestParamsRunFiltered is testing the test runner with parameterized tests // while applying a filter. func TestParamsRunFiltered(t *testing.T) { - pattern, count := "inrun failure", atomic.Int32{} + pattern, count := "inrun-failure", atomic.Int32{} expect := commonTestCases.FilterBy(pattern) assert.NotEmpty(t, expect) @@ -103,7 +103,7 @@ func TestSliceRun(t *testing.T) { // TestSliceRunFiltered is testing the test runner with slices while applying // a filter. func TestSliceRunFiltered(t *testing.T) { - pattern, count := "inrun success", atomic.Int32{} + pattern, count := "inrun-success", atomic.Int32{} expect := commonTestCases.FilterBy(pattern) assert.NotEmpty(t, expect) @@ -160,7 +160,7 @@ type ( var filterCases = map[string]filterParams{ // Test filter by name variants - "include single match": { + "include-single-match": { cases: map[string]Any{ "alpha-test": {}, "beta-test": {}, @@ -174,7 +174,7 @@ var filterCases = map[string]filterParams{ }, }, - "exclude single match": { + "exclude-single-match": { cases: map[string]Any{ "alpha-test": {}, "beta-test": {}, @@ -189,7 +189,7 @@ var filterCases = map[string]filterParams{ }, }, - "include space normalized": { + "include-space-normalized": { cases: map[string]Any{ "alpha-test": {}, "beta-test": {}, @@ -204,7 +204,7 @@ var filterCases = map[string]filterParams{ }, }, - "exclude space normalized": { + "exclude-space-normalized": { cases: map[string]Any{ "alpha-test": {}, "beta-test": {}, @@ -218,7 +218,7 @@ var filterCases = map[string]filterParams{ }, }, - "include no matches": { + "include-no-matches": { cases: map[string]Any{ "alpha-test": {}, "beta-test": {}, @@ -229,7 +229,7 @@ var filterCases = map[string]filterParams{ expect: map[string]bool{}, }, - "exclude all matches": { + "exclude-all-matches": { cases: map[string]Any{ "alpha-test": {}, "beta-test": {}, @@ -242,10 +242,10 @@ var filterCases = map[string]filterParams{ }, // Test with pattern/os/arch combined - "pattern filter include": { + "pattern-filter-include": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, + "alpha-test": {}, + "beta-test": {}, "gamma": {}, }, apply: func(f FactoryAny) FactoryAny { @@ -256,10 +256,10 @@ var filterCases = map[string]filterParams{ }, }, - "pattern filter exclude with spaces": { + "pattern-filter-exclude-with-spaces": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, + "alpha-test": {}, + "beta-test": {}, "gamma": {}, }, apply: func(f FactoryAny) FactoryAny { @@ -273,9 +273,9 @@ var filterCases = map[string]filterParams{ }, }, - "os filter current os": { + "os-filter-current-os": { cases: map[string]Any{ - "test case": {}, + "test-case": {}, }, apply: func(f FactoryAny) FactoryAny { return f.Filter(test.OS[Any](runtime.GOOS)) @@ -285,9 +285,9 @@ var filterCases = map[string]filterParams{ }, }, - "os filter different os": { + "os-filter-different-os": { cases: map[string]Any{ - "test case": {}, + "test-case": {}, }, apply: func(f test.Factory[Any]) test.Factory[Any] { other := "linux" @@ -299,9 +299,9 @@ var filterCases = map[string]filterParams{ expect: map[string]bool{}, }, - "arch filter current arch": { + "arch-filter-current-arch": { cases: map[string]Any{ - "test case": {}, + "test-case": {}, }, apply: func(f FactoryAny) FactoryAny { return f.Filter(test.Arch[Any](runtime.GOARCH)) @@ -311,9 +311,9 @@ var filterCases = map[string]filterParams{ }, }, - "arch filter different arch": { + "arch-filter-different-arch": { cases: map[string]Any{ - "test case": {}, + "test-case": {}, }, apply: func(f test.Factory[Any]) test.Factory[Any] { other := "amd64" @@ -325,11 +325,11 @@ var filterCases = map[string]filterParams{ expect: map[string]bool{}, }, - "multiple filters combined": { + "multiple-filters-combined": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, - "gamma test": {}, + "alpha-test": {}, + "beta-test": {}, + "gamma-test": {}, }, apply: func(f test.Factory[Any]) test.Factory[Any] { return f. @@ -347,10 +347,10 @@ var filterCases = map[string]filterParams{ }, // Tests with and/or combined - "and filter all match": { + "and-filter-all-match": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, + "alpha-test": {}, + "beta-test": {}, "gamma": {}, }, apply: func(f FactoryAny) FactoryAny { @@ -366,10 +366,10 @@ var filterCases = map[string]filterParams{ }, }, - "and filter no match": { + "and-filter-no-match": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, + "alpha-test": {}, + "beta-test": {}, "gamma": {}, }, apply: func(f FactoryAny) FactoryAny { @@ -383,10 +383,10 @@ var filterCases = map[string]filterParams{ expect: map[string]bool{}, }, - "or filter single match": { + "or-filter-single-match": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, + "alpha-test": {}, + "beta-test": {}, "gamma": {}, }, apply: func(f FactoryAny) FactoryAny { @@ -405,11 +405,11 @@ var filterCases = map[string]filterParams{ }, }, - "or filter multiple match": { + "or-filter-multiple-match": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, - "gamma test": {}, + "alpha-test": {}, + "beta-test": {}, + "gamma-test": {}, }, apply: func(f FactoryAny) FactoryAny { return f.Filter(test.Or( @@ -427,10 +427,10 @@ var filterCases = map[string]filterParams{ }, }, - "or filter no match": { + "or-filter-no-match": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, + "alpha-test": {}, + "beta-test": {}, }, apply: func(f FactoryAny) FactoryAny { return f.Filter(test.Or( @@ -445,11 +445,11 @@ var filterCases = map[string]filterParams{ expect: map[string]bool{}, }, - "and or combined": { + "and-or-combined": { cases: map[string]Any{ - "alpha test": {}, - "beta test": {}, - "gamma test": {}, + "alpha-test": {}, + "beta-test": {}, + "gamma-test": {}, "delta": {}, }, apply: func(f FactoryAny) FactoryAny {