| 1 | package goldiescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.12 fmt/" |
| 5 | "io/ioutilscip-go gomod github.com/golang/go/src go1.12 `io/ioutil`/" |
| 6 | "osscip-go gomod github.com/golang/go/src go1.12 os/" |
| 7 | "path/filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/" |
| 8 | "testingscip-go gomod github.com/golang/go/src go1.12 testing/" |
| 9 | "timescip-go gomod github.com/golang/go/src go1.12 time/" |
| 10 | |
| 11 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/" |
| 12 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/require`/" |
| 13 | ) |
| 14 | |
| 15 | func TestGoldenFileNamescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/TestGoldenFileName().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 16 | tests := map[string]struct { |
| 17 | name string |
| 18 | options []Optionscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Option# |
| 19 | expected string |
| 20 | }{ |
| 21 | "using defaults": { |
| 22 | name: "example", |
| 23 | expected: fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.12 fmt/Sprintf().("%s/%s%s", defaultFixtureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/defaultFixtureDir., "example", defaultFileNameSuffixscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/defaultFileNameSuffix.), |
| 24 | }, |
| 25 | "with custom suffix": { |
| 26 | name: "example", |
| 27 | options: []Optionscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Option#{ |
| 28 | WithNameSuffixscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/WithNameSuffix().(".txt"), |
| 29 | }, |
| 30 | expected: fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.12 fmt/Sprintf().("%s/%s%s", defaultFixtureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/defaultFixtureDir., "example", ".txt"), |
| 31 | }, |
| 32 | "with custom fixture dir": { |
| 33 | name: "example", |
| 34 | options: []Optionscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Option#{ |
| 35 | WithFixtureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/WithFixtureDir().("fixtures"), |
| 36 | }, |
| 37 | expected: fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.12 fmt/Sprintf().("%s/%s%s", "fixtures", "example", defaultFileNameSuffixscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/defaultFileNameSuffix.), |
| 38 | }, |
| 39 | "using test name for dir": { |
| 40 | name: "example", |
| 41 | options: []Optionscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Option#{ |
| 42 | WithTestNameForDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/WithTestNameForDir().(true), |
| 43 | }, |
| 44 | expected: fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.12 fmt/Sprintf().("%s/%s/%s%s", defaultFixtureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/defaultFixtureDir., t.Namescip-go gomod github.com/golang/go/src go1.12 testing/common#Name().(), "example", defaultFileNameSuffixscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/defaultFileNameSuffix.), |
| 45 | }, |
| 46 | "using sub test name for dir": { |
| 47 | name: "example", |
| 48 | options: []Optionscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Option#{ |
| 49 | WithSubTestNameForDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/WithSubTestNameForDir().(true), |
| 50 | }, |
| 51 | expected: fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.12 fmt/Sprintf().("%s/%s/%s%s", defaultFixtureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/defaultFixtureDir., "using_sub_test_name_for_dir", "example", defaultFileNameSuffixscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/defaultFileNameSuffix.), |
| 52 | }, |
| 53 | } |
| 54 | |
| 55 | for name, test := range tests { |
| 56 | t.Runscip-go gomod github.com/golang/go/src go1.12 testing/T#Run().(name, func(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 57 | g := Newscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/New().(t, test.options...) |
| 58 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Equal().(t, test.expected, g.GoldenFileNamescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#GoldenFileName().(t, test.name)) |
| 59 | }) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func TestEnsureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/TestEnsureDir().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 64 | tests := map[string]struct { |
| 65 | dir string |
| 66 | shouldExist bool |
| 67 | fileExist bool |
| 68 | err interface{} |
| 69 | }{ |
| 70 | "with existing directory": { |
| 71 | dir: "example1", |
| 72 | shouldExist: true, |
| 73 | err: nil, |
| 74 | }, |
| 75 | "without existing directory": { |
| 76 | dir: "example2", |
| 77 | shouldExist: false, |
| 78 | fileExist: false, |
| 79 | err: nil, |
| 80 | }, |
| 81 | "with existing deep directory structure": { |
| 82 | dir: "now/still/works", |
| 83 | shouldExist: true, |
| 84 | err: nil, |
| 85 | }, |
| 86 | "error, fixture directory is a file": { |
| 87 | dir: "this/will/not", |
| 88 | shouldExist: false, |
| 89 | fileExist: true, |
| 90 | err: newErrFixtureDirectoryIsFilescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/newErrFixtureDirectoryIsFile().(filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Join().(osscip-go gomod github.com/golang/go/src go1.12 os/.TempDirscip-go gomod github.com/golang/go/src go1.12 os/TempDir().(), "this/will/not")), |
| 91 | }, |
| 92 | } |
| 93 | |
| 94 | for name, test := range tests { |
| 95 | t.Runscip-go gomod github.com/golang/go/src go1.12 testing/T#Run().(name, func(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 96 | g := Newscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/New().(t) |
| 97 | target := filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Join().(osscip-go gomod github.com/golang/go/src go1.12 os/.TempDirscip-go gomod github.com/golang/go/src go1.12 os/TempDir().(), test.dir) |
| 98 | |
| 99 | if test.shouldExist { |
| 100 | err := osscip-go gomod github.com/golang/go/src go1.12 os/.MkdirAllscip-go gomod github.com/golang/go/src go1.12 os/MkdirAll().(target, g.dirPermsscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#dirPerms.) |
| 101 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 102 | } |
| 103 | |
| 104 | if test.fileExist { |
| 105 | err := osscip-go gomod github.com/golang/go/src go1.12 os/.MkdirAllscip-go gomod github.com/golang/go/src go1.12 os/MkdirAll().(filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Dir().(target), g.dirPermsscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#dirPerms.) |
| 106 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 107 | |
| 108 | f, err := osscip-go gomod github.com/golang/go/src go1.12 os/.Createscip-go gomod github.com/golang/go/src go1.12 os/Create().(target) |
| 109 | requirescip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 110 | err = f.Closescip-go gomod github.com/golang/go/src go1.12 os/File#Close().() |
| 111 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 112 | } |
| 113 | |
| 114 | err := g.ensureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#ensureDir().(target) |
| 115 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Equal().(t, test.err, err) |
| 116 | if err != nil { |
| 117 | return |
| 118 | } |
| 119 | |
| 120 | s, err := osscip-go gomod github.com/golang/go/src go1.12 os/.Statscip-go gomod github.com/golang/go/src go1.12 os/Stat().(target) |
| 121 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 122 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/True().(t, s.IsDirscip-go gomod github.com/golang/go/src go1.12 `io/fs`/FileInfo#IsDir().()) |
| 123 | }) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | // TODO: This test could use a little <3. It should test some more negative |
| 128 | // cases. |
| 129 | func TestUpdatescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/TestUpdate().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 130 | tests := map[string]struct { |
| 131 | name string |
| 132 | data []byte |
| 133 | err error |
| 134 | }{ |
| 135 | "successful update": { |
| 136 | name: "abc", |
| 137 | data: []byte("some example data"), |
| 138 | err: nil, |
| 139 | }, |
| 140 | } |
| 141 | |
| 142 | for name, test := range tests { |
| 143 | t.Runscip-go gomod github.com/golang/go/src go1.12 testing/T#Run().(name, func(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 144 | g := Newscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/New().(t) |
| 145 | err := g.Updatescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#Update().(t, test.name, test.data) |
| 146 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Equal().(t, test.err, err) |
| 147 | |
| 148 | data, err := ioutilscip-go gomod github.com/golang/go/src go1.12 `io/ioutil`/.ReadFilescip-go gomod github.com/golang/go/src go1.12 `io/ioutil`/ReadFile().(g.GoldenFileNamescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#GoldenFileName().(t, test.name)) |
| 149 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 150 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Equal().(t, test.data, data) |
| 151 | |
| 152 | err = osscip-go gomod github.com/golang/go/src go1.12 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.12 os/RemoveAll().(g.fixtureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#fixtureDir.) |
| 153 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 154 | }) |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | func TestDiffEnginesscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/TestDiffEngines().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 159 | type engine struct { |
| 160 | engine DiffEnginescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/DiffEngine# |
| 161 | diff string |
| 162 | } |
| 163 | |
| 164 | tests := map[string]struct { |
| 165 | actual string |
| 166 | expected string |
| 167 | engine engine |
| 168 | }{ |
| 169 | "simple": { |
| 170 | actual: "Lorem ipsum dolor.", |
| 171 | expected: "Lorem dolor sit amet.", |
| 172 | engine: engine{ |
| 173 | engine: Simplescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Simple., |
| 174 | diff: `Expected: Lorem dolor sit amet. |
| 175 | Got: Lorem ipsum dolor.`}, |
| 176 | }, |
| 177 | "classic": { |
| 178 | actual: "Lorem ipsum dolor.", |
| 179 | expected: "Lorem dolor sit amet.", |
| 180 | engine: engine{ |
| 181 | engine: ClassicDiffscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/ClassicDiff., |
| 182 | diff: `--- Expected |
| 183 | +++ Actual |
| 184 | @@ -1 +1 @@ |
| 185 | -Lorem dolor sit amet. |
| 186 | +Lorem ipsum dolor. |
| 187 | `}, |
| 188 | }, |
| 189 | "colored": { |
| 190 | actual: "Lorem ipsum dolor.", |
| 191 | expected: "Lorem dolor sit amet.", |
| 192 | engine: engine{ |
| 193 | engine: ColoredDiffscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/ColoredDiff., |
| 194 | diff: "Lorem \x1b[31mipsum \x1b[0mdolor\x1b[32m sit amet\x1b[0m.", |
| 195 | }, |
| 196 | }, |
| 197 | } |
| 198 | |
| 199 | for name, test := range tests { |
| 200 | t.Runscip-go gomod github.com/golang/go/src go1.12 testing/T#Run().(name, func(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 201 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Equal().( |
| 202 | t, |
| 203 | test.engine.diff, |
| 204 | Diffscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Diff().(test.engine.engine, test.actual, test.expected), |
| 205 | ) |
| 206 | }) |
| 207 | } |
| 208 | |
| 209 | } |
| 210 | |
| 211 | func TestCleanFunctionscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/TestCleanFunction().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 212 | savedCleanState := *cleanscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/clean. |
| 213 | *cleanscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/clean. = false |
| 214 | savedUpdateState := *updatescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/update. |
| 215 | *updatescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/update. = true |
| 216 | tsscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/ts. = timescip-go gomod github.com/golang/go/src go1.12 time/.Nowscip-go gomod github.com/golang/go/src go1.12 time/Now().() |
| 217 | |
| 218 | sampleData := []byte("sample data") |
| 219 | fixtureDir := "test-fixtures" |
| 220 | fixtureSubDirA := fixtureDir + "/a" |
| 221 | fixtureSubDirB := fixtureDir + "/b" |
| 222 | suffix := ".golden" |
| 223 | |
| 224 | // The first time running go test, with -update, without -clean |
| 225 | firstTests := []struct { |
| 226 | fixtureDirWithSub string |
| 227 | filePrefix string |
| 228 | }{ |
| 229 | {fixtureDirWithSub: fixtureSubDirA, filePrefix: "example-a1"}, |
| 230 | {fixtureDirWithSub: fixtureSubDirA, filePrefix: "example-a2"}, |
| 231 | {fixtureDirWithSub: fixtureSubDirB, filePrefix: "example-b1"}, |
| 232 | {fixtureDirWithSub: fixtureSubDirB, filePrefix: "example-b2"}, |
| 233 | } |
| 234 | |
| 235 | for i, tt := range firstTests { |
| 236 | g := Newscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/New().(t, |
| 237 | WithFixtureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/WithFixtureDir().(tt.fixtureDirWithSub), |
| 238 | WithNameSuffixscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/WithNameSuffix().(suffix), |
| 239 | ) |
| 240 | |
| 241 | t.Runscip-go gomod github.com/golang/go/src go1.12 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintscip-go gomod github.com/golang/go/src go1.12 fmt/Sprint().(i), func(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 242 | g.Assertscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#Assert().(t, tt.filePrefix, sampleData) |
| 243 | }) |
| 244 | |
| 245 | fullPath := fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.12 fmt/Sprintf().("%s%s", |
| 246 | filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Join().(tt.fixtureDirWithSub, tt.filePrefix), |
| 247 | suffix, |
| 248 | ) |
| 249 | |
| 250 | _, err := osscip-go gomod github.com/golang/go/src go1.12 os/.Statscip-go gomod github.com/golang/go/src go1.12 os/Stat().(fullPath) |
| 251 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 252 | } |
| 253 | |
| 254 | *cleanscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/clean. = true |
| 255 | tsscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/ts. = timescip-go gomod github.com/golang/go/src go1.12 time/.Nowscip-go gomod github.com/golang/go/src go1.12 time/Now().() |
| 256 | |
| 257 | // The second time running go test, with -update and -clean |
| 258 | secondTests := []struct { |
| 259 | fixtureDirWithSub string |
| 260 | filePrefix string |
| 261 | }{ |
| 262 | {fixtureDirWithSub: fixtureSubDirA, filePrefix: "example-a3"}, |
| 263 | {fixtureDirWithSub: fixtureSubDirA, filePrefix: "example-a4"}, |
| 264 | {fixtureDirWithSub: fixtureSubDirB, filePrefix: "example-b3"}, |
| 265 | {fixtureDirWithSub: fixtureSubDirB, filePrefix: "example-b4"}, |
| 266 | } |
| 267 | |
| 268 | for i, tt := range secondTests { |
| 269 | g := Newscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/New().(t, |
| 270 | WithFixtureDirscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/WithFixtureDir().(tt.fixtureDirWithSub), |
| 271 | WithNameSuffixscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/WithNameSuffix().(suffix), |
| 272 | ) |
| 273 | |
| 274 | t.Runscip-go gomod github.com/golang/go/src go1.12 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintscip-go gomod github.com/golang/go/src go1.12 fmt/Sprint().(i), func(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 275 | g.Assertscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/Goldie#Assert().(t, tt.filePrefix, sampleData) |
| 276 | }) |
| 277 | |
| 278 | fullPath := fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.12 fmt/Sprintf().("%s%s", |
| 279 | filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Join().(tt.fixtureDirWithSub, tt.filePrefix), |
| 280 | suffix, |
| 281 | ) |
| 282 | |
| 283 | _, err := osscip-go gomod github.com/golang/go/src go1.12 os/.Statscip-go gomod github.com/golang/go/src go1.12 os/Stat().(fullPath) |
| 284 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 285 | } |
| 286 | |
| 287 | // make sure output files of the first run doesnt exist |
| 288 | for _, tt := range firstTests { |
| 289 | fullPath := fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.12 fmt/Sprintf().("%s%s", |
| 290 | filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Join().(tt.fixtureDirWithSub, tt.filePrefix), |
| 291 | suffix, |
| 292 | ) |
| 293 | |
| 294 | _, err := osscip-go gomod github.com/golang/go/src go1.12 os/.Statscip-go gomod github.com/golang/go/src go1.12 os/Stat().(fullPath) |
| 295 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Error().(t, err) |
| 296 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/True().(t, osscip-go gomod github.com/golang/go/src go1.12 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.12 os/IsNotExist().(err)) |
| 297 | } |
| 298 | |
| 299 | err := osscip-go gomod github.com/golang/go/src go1.12 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.12 os/RemoveAll().(fixtureDir) |
| 300 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err) |
| 301 | *cleanscip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/clean. = savedCleanState |
| 302 | *updatescip-go gomod github.com/sebdah/goldie . `github.com/sebdah/goldie`/update. = savedUpdateState |
| 303 | } |