paralleltest linter doesn't correctly handle table-driven tests (https://github.com/kunwardeep/paralleltest/issues/8) nolint:paralleltest
(t *testing.T)
| 117 | // paralleltest linter doesn't correctly handle table-driven tests (https://github.com/kunwardeep/paralleltest/issues/8) |
| 118 | // nolint:paralleltest |
| 119 | func TestCheckLatestVersion(t *testing.T) { |
| 120 | t.Parallel() |
| 121 | |
| 122 | type test struct { |
| 123 | currentVersion uint |
| 124 | existingVersions []uint |
| 125 | expectedResult string |
| 126 | } |
| 127 | |
| 128 | tests := []test{ |
| 129 | // successful cases |
| 130 | {1, []uint{1}, ""}, |
| 131 | {3, []uint{1, 2, 3}, ""}, |
| 132 | {3, []uint{1, 3}, ""}, |
| 133 | |
| 134 | // failure cases |
| 135 | {1, []uint{1, 2}, "current version is 1, but later version 2 exists"}, |
| 136 | {2, []uint{1, 2, 3}, "current version is 2, but later version 3 exists"}, |
| 137 | {4, []uint{1, 2, 3}, "get previous migration: prev for version 4 : file does not exist"}, |
| 138 | {4, []uint{1, 2, 3, 5}, "get previous migration: prev for version 4 : file does not exist"}, |
| 139 | } |
| 140 | |
| 141 | for i, tc := range tests { |
| 142 | t.Run(fmt.Sprintf("entry %d", i), func(t *testing.T) { |
| 143 | t.Parallel() |
| 144 | |
| 145 | driver, _ := stub.WithInstance(nil, &stub.Config{}) |
| 146 | stub, ok := driver.(*stub.Stub) |
| 147 | require.True(t, ok) |
| 148 | for _, version := range tc.existingVersions { |
| 149 | stub.Migrations.Append(&source.Migration{ |
| 150 | Version: version, |
| 151 | Identifier: "", |
| 152 | Direction: source.Up, |
| 153 | Raw: "", |
| 154 | }) |
| 155 | } |
| 156 | |
| 157 | err := migrations.CheckLatestVersion(driver, tc.currentVersion) |
| 158 | var errMessage string |
| 159 | if err != nil { |
| 160 | errMessage = err.Error() |
| 161 | } |
| 162 | require.Equal(t, tc.expectedResult, errMessage) |
| 163 | }) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | func setupMigrate(t *testing.T, db *sql.DB, name, path string) (source.Driver, *migrate.Migrate) { |
| 168 | t.Helper() |
nothing calls this directly
no test coverage detected