Skip to content

Commit

Permalink
Add tparallel linter and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges committed Jul 9, 2021
1 parent 5df37e7 commit 5f2f91b
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 11 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ linters:
enable:
- gofmt
- megacheck
- tparallel
presets:
- bugs
- unused
Expand Down
2 changes: 2 additions & 0 deletions hack/generated/pkg/duration/duration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func TestDuration_String(t *testing.T) {
}

func TestDuration_JSON(t *testing.T) {
t.Parallel()

cases := []struct {
Name string
JSON string
Expand Down
5 changes: 4 additions & 1 deletion hack/generator/pkg/astbuilder/literals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
package astbuilder

import (
. "github.com/onsi/gomega"
"testing"

. "github.com/onsi/gomega"
)

func Test_LiteralString(t *testing.T) {
t.Parallel()

cases := []struct {
name string
original string
Expand Down
2 changes: 2 additions & 0 deletions hack/generator/pkg/astmodel/array_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestArrayType_Equals_WhenGivenType_ReturnsExpectedResult(t *testing.T) {
t.Parallel()

strArray := NewArrayType(StringType)
intArray := NewArrayType(IntType)
otherStrArray := NewArrayType(StringType)
Expand Down
1 change: 1 addition & 0 deletions hack/generator/pkg/astmodel/enum_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func Test_EnumTypeBaseType_AfterConstruction_ReturnsExpectedType(t *testing.T) {
*/

func Test_EnumTypeEquals_GivenEnums_ReturnsExpectedResult(t *testing.T) {
t.Parallel()

enum := NewEnumType(StringType, aboveValue, underValue)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestMakeExternalPackageReference_GivenPath_ReturnsInstanceWithPath(t *testing.T) {
t.Parallel()

cases := []struct {
name string
path string
Expand All @@ -32,6 +34,8 @@ func TestMakeExternalPackageReference_GivenPath_ReturnsInstanceWithPath(t *testi
}

func TestExternalPackageReferences_ReturnExpectedProperties(t *testing.T) {
t.Parallel()

cases := []struct {
name string
path string
Expand All @@ -58,6 +62,7 @@ func TestExternalPackageReferences_ReturnExpectedProperties(t *testing.T) {
}

func TestExternalPackageReferences_Equals_GivesExpectedResults(t *testing.T) {
t.Parallel()

fmtRef := MakeExternalPackageReference("fmt")
astRef := MakeExternalPackageReference("go/ast")
Expand Down Expand Up @@ -90,6 +95,8 @@ func TestExternalPackageReferences_Equals_GivesExpectedResults(t *testing.T) {
}

func TestExternalPackageReferenceIsPreview(t *testing.T) {
t.Parallel()

fmtRef := MakeExternalPackageReference("fmt")
astRef := MakeExternalPackageReference("go/ast")
otherRef := makeTestLocalPackageReference("group", "package")
Expand Down
4 changes: 4 additions & 0 deletions hack/generator/pkg/astmodel/flagged_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func TestFlaggedType_WithoutFlag_GivenUnusedFlag_ReturnsSameInstance(t *testing.
*/

func TestFlaggedType_Equals_GivenOther_HasExpectedResult(t *testing.T) {
t.Parallel()

armString := NewFlaggedType(StringType, ARMFlag)
armInt := NewFlaggedType(IntType, ARMFlag)
storageString := NewFlaggedType(StringType, StorageFlag)
Expand Down Expand Up @@ -120,6 +122,8 @@ func TestFlaggedType_Equals_GivenOther_HasExpectedResult(t *testing.T) {
*/

func TestFlaggedType_String_GivenTypeAndTag_ReturnsExpectedString(t *testing.T) {
t.Parallel()

flaggedString := NewFlaggedType(StringType, OneOfFlag)
cases := []struct {
name string
Expand Down
8 changes: 8 additions & 0 deletions hack/generator/pkg/astmodel/identifier_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func Test_CreateIdentifier_GivenName_ReturnsExpectedIdentifier(t *testing.T) {
t.Parallel()

cases := []struct {
name string
visibility Visibility
Expand Down Expand Up @@ -58,6 +60,8 @@ func Test_CreateIdentifier_GivenName_ReturnsExpectedIdentifier(t *testing.T) {
}

func Test_SliceIntoWords_GivenIdentifier_ReturnsExpectedSlice(t *testing.T) {
t.Parallel()

cases := []struct {
identifier string
expected []string
Expand Down Expand Up @@ -89,6 +93,8 @@ func Test_SliceIntoWords_GivenIdentifier_ReturnsExpectedSlice(t *testing.T) {
}

func Test_TransformToSnakeCase_ReturnsExpectedString(t *testing.T) {
t.Parallel()

cases := []struct {
string string
expected string
Expand Down Expand Up @@ -120,6 +126,8 @@ func Test_TransformToSnakeCase_ReturnsExpectedString(t *testing.T) {
}

func Test_SimplifyIdentifier_GivenContextAndName_ReturnsExpectedResult(t *testing.T) {
t.Parallel()

cases := []struct {
context string
identifier string
Expand Down
6 changes: 6 additions & 0 deletions hack/generator/pkg/astmodel/local_package_reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func makeTestLocalPackageReference(group string, version string) LocalPackageRef
}

func TestMakeLocalPackageReference_GivenGroupAndPackage_ReturnsInstanceWithProperties(t *testing.T) {
t.Parallel()

cases := []struct {
name string
group string
Expand All @@ -42,6 +44,8 @@ func TestMakeLocalPackageReference_GivenGroupAndPackage_ReturnsInstanceWithPrope
}

func TestLocalPackageReferences_ReturnExpectedProperties(t *testing.T) {
t.Parallel()

cases := []struct {
name string
group string
Expand Down Expand Up @@ -87,6 +91,7 @@ func TestLocalPackageReferences_ReturnExpectedProperties(t *testing.T) {
}

func TestLocalPackageReferences_Equals_GivesExpectedResults(t *testing.T) {
t.Parallel()

batchRef := makeTestLocalPackageReference("microsoft.batch", "v20200901")
olderRef := makeTestLocalPackageReference("microsoft.batch", "v20150101")
Expand Down Expand Up @@ -122,6 +127,7 @@ func TestLocalPackageReferences_Equals_GivesExpectedResults(t *testing.T) {
}

func TestLocalPackageReferenceIsPreview(t *testing.T) {
t.Parallel()

cases := []struct {
name string
Expand Down
1 change: 1 addition & 0 deletions hack/generator/pkg/astmodel/map_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestMapType_Equals_WhenGivenType_ReturnsExpectedResult(t *testing.T) {
t.Parallel()

strToStr := NewMapType(StringType, StringType)
strToBool := NewMapType(StringType, BoolType)
Expand Down
14 changes: 7 additions & 7 deletions hack/generator/pkg/astmodel/meta_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestAsPrimitiveType(t *testing.T) {
t.Parallel()

objectType := NewObjectType()
arrayType := NewArrayType(StringType)
Expand Down Expand Up @@ -56,12 +57,12 @@ func TestAsPrimitiveType(t *testing.T) {
g.Expect(actual).To(Equal(c.expected))
g.Expect(ok).To(BeTrue())
}

})
}
}

func TestAsObjectType(t *testing.T) {
t.Parallel()

objectType := NewObjectType()
arrayType := NewArrayType(StringType)
Expand Down Expand Up @@ -106,12 +107,12 @@ func TestAsObjectType(t *testing.T) {
g.Expect(actual).To(Equal(c.expected))
g.Expect(ok).To(BeTrue())
}

})
}
}

func TestAsArrayType(t *testing.T) {
t.Parallel()

objectType := NewObjectType()
arrayType := NewArrayType(StringType)
Expand Down Expand Up @@ -156,12 +157,12 @@ func TestAsArrayType(t *testing.T) {
g.Expect(actual).To(Equal(c.expected))
g.Expect(ok).To(BeTrue())
}

})
}
}

func TestAsMapType(t *testing.T) {
t.Parallel()

objectType := NewObjectType()
arrayType := NewArrayType(StringType)
Expand Down Expand Up @@ -206,12 +207,12 @@ func TestAsMapType(t *testing.T) {
g.Expect(actual).To(Equal(c.expected))
g.Expect(ok).To(BeTrue())
}

})
}
}

func TestAsOptionalType(t *testing.T) {
t.Parallel()

objectType := NewObjectType()
arrayType := NewArrayType(StringType)
Expand Down Expand Up @@ -254,12 +255,12 @@ func TestAsOptionalType(t *testing.T) {
g.Expect(actual).To(Equal(c.expected))
g.Expect(ok).To(BeTrue())
}

})
}
}

func TestAsEnumType(t *testing.T) {
t.Parallel()

objectType := NewObjectType()
arrayType := NewArrayType(StringType)
Expand Down Expand Up @@ -302,12 +303,12 @@ func TestAsEnumType(t *testing.T) {
g.Expect(actual).To(Equal(c.expected))
g.Expect(ok).To(BeTrue())
}

})
}
}

func TestAsTypeName(t *testing.T) {
t.Parallel()

objectType := NewObjectType()
arrayType := NewArrayType(StringType)
Expand Down Expand Up @@ -350,7 +351,6 @@ func TestAsTypeName(t *testing.T) {
g.Expect(actual).To(Equal(c.expected))
g.Expect(ok).To(BeTrue())
}

})
}
}
1 change: 1 addition & 0 deletions hack/generator/pkg/astmodel/object_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func Test_EmbeddedProperties_GivenObjectWithProperties_ReturnsExpectedSortedSlic
*/

func TestObjectType_Equals_WhenGivenType_ReturnsExpectedResult(t *testing.T) {
t.Parallel()

clanName := NewStringPropertyDefinition("Clan")
testcaseA := NewFakeTestCase("testcaseA")
Expand Down
6 changes: 5 additions & 1 deletion hack/generator/pkg/astmodel/package_import_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func TestRemove_WhenItemNotInSet_LeavesSetWithoutIt(t *testing.T) {
*/

func TestByNameInGroups_AppliesExpectedOrdering(t *testing.T) {
t.Parallel()

fmtRef := MakeExternalPackageReference("fmt")
testingRef := MakeExternalPackageReference("testing")
Expand Down Expand Up @@ -265,6 +266,7 @@ func TestPackageImportSet_ResolveConflicts_GivenExplicitlyNamedConflicts_Returns
}

func TestPackageImportSet_ResolveConflicts_GivenImplicityNamedConflicts_AssignsExpectedNames(t *testing.T) {
t.Parallel()

createSet := func(refs ...PackageReference) *PackageImportSet {
result := NewPackageImportSet()
Expand Down Expand Up @@ -303,7 +305,8 @@ func TestPackageImportSet_ResolveConflicts_GivenImplicityNamedConflicts_AssignsE
"Import conflicts with versioned resolution (ii)",
createSet(emailTestRef, networkTestRef, emailTestAltRef, networkTestAltRef),
networkTestRef,
"networkv20180801"},
"networkv20180801",
},
{
"Import conflicts with versioned resolution (iii)",
createSet(emailTestRef, networkTestRef, emailTestAltRef, networkTestAltRef),
Expand Down Expand Up @@ -339,6 +342,7 @@ func TestPackageImportSet_ResolveConflicts_GivenImplicityNamedConflicts_AssignsE
*/

func Test_PackageSet_OrderImports(t *testing.T) {
t.Parallel()

alphaRef := MakeExternalPackageReference("alpha")
betaRef := MakeExternalPackageReference("beta")
Expand Down
4 changes: 4 additions & 0 deletions hack/generator/pkg/astmodel/package_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func Test_PackageImportWithName_GivenExistingName_ReturnsEqualInstance(t *testin
*/

func TestPackageImport_Equals(t *testing.T) {
t.Parallel()

var zeroPkgRef PackageImport
localPkgRef := makeTestLocalPackageReference("group", "ver")
localPkgImport := NewPackageImport(localPkgRef)
Expand Down Expand Up @@ -107,6 +109,8 @@ func TestPackageImport_Equals(t *testing.T) {
*/

func TestPackageImport_ServiceNameForImport_GivenImport_ReturnsExpectedName(t *testing.T) {
t.Parallel()

cases := []struct {
name string
ref PackageReference
Expand Down
4 changes: 4 additions & 0 deletions hack/generator/pkg/astmodel/package_reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func TestSortPackageReferencesByPathAndVersion(t *testing.T) {
}

func TestComparePackageReferencesByPathAndVersion(t *testing.T) {
t.Parallel()

cases := []struct {
name string
left string
Expand Down Expand Up @@ -74,6 +76,8 @@ func TestComparePackageReferencesByPathAndVersion(t *testing.T) {
}

func TestVersionComparerCompareNumeric(t *testing.T) {
t.Parallel()

cases := []struct {
name string
left string
Expand Down
2 changes: 2 additions & 0 deletions hack/generator/pkg/astmodel/primitive_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestPrimitiveType_Equals_WhenGivenType_ReturnsExpectedResult(t *testing.T) {
t.Parallel()

otherType := NewArrayType(IntType)

cases := []struct {
Expand Down
6 changes: 6 additions & 0 deletions hack/generator/pkg/astmodel/property_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ func Test_PropertyDefinitionMakeRequired_WhenTypeOptionalAndIsRequired_ReturnsNe
}

func Test_PropertyDefinitionMakeRequired_PropertyTypeArrayAndMap(t *testing.T) {
t.Parallel()

cases := []struct {
name string
propertyType Type
Expand Down Expand Up @@ -402,6 +404,8 @@ func Test_PropertyDefinitionMakeOptional_WhenTypeMandatoryAndIsRequiredFalse_Ret
}

func Test_PropertyDefinitionMakeOptional_PropertyTypeArrayAndMap(t *testing.T) {
t.Parallel()

cases := []struct {
name string
propertyType Type
Expand Down Expand Up @@ -474,6 +478,8 @@ func Test_PropertyDefinition_WithValidation_ReturnsNewPropertyDefinition(t *test
*/

func TestPropertyDefinition_Equals_WhenGivenPropertyDefinition_ReturnsExpectedResult(t *testing.T) {
t.Parallel()

strProperty := createStringProperty("FullName", "Full Legal Name")
otherStrProperty := createStringProperty("FullName", "Full Legal Name")

Expand Down
Loading

0 comments on commit 5f2f91b

Please sign in to comment.