-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cleanup public API * Move alias * Test coverage * Rename
- Loading branch information
Showing
13 changed files
with
101 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package formatting | ||
|
||
type encoder interface { | ||
Encode(v interface{}) error | ||
} | ||
|
||
type decoder interface { | ||
Decode(v interface{}) error | ||
} | ||
|
||
func format(encoder encoder, decoder decoder) error { | ||
var decoded interface{} | ||
err := decoder.Decode(&decoded) | ||
if err != nil { | ||
return err | ||
} | ||
return encoder.Encode(decoded) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package gold | ||
|
||
import ( | ||
"github.com/eberkund/rose/formatting" | ||
) | ||
|
||
// AssertEqualsJSON compares a JSON string to the golden file. Data is | ||
// noramlized before comparing so data which is formatted differently but | ||
// semantically equivalent will not fail. | ||
func (g *Gold) AssertEqualsJSON(goldenPath, actual string) { | ||
g.t.Helper() | ||
g.verify(g.assert(goldenPath, actual, formatting.JSON)) | ||
} | ||
|
||
// AssertEqualsHTML compares an HTML string to the golden file. Data is | ||
// noramlized before comparing so data which is formatted differently but | ||
// semantically equivalent will not fail. | ||
func (g *Gold) AssertEqualsHTML(goldenPath, actual string) { | ||
g.t.Helper() | ||
g.verify(g.assert(goldenPath, actual, formatting.HTML)) | ||
} | ||
|
||
// AssertEqualsTOML compares a TOML string to the golden file. Data is | ||
// noramlized before comparing so data which is formatted differently but | ||
// semantically equivalent will not fail. | ||
func (g *Gold) AssertEqualsTOML(goldenPath, actual string) { | ||
g.t.Helper() | ||
g.verify(g.assert(goldenPath, actual, formatting.TOML)) | ||
} | ||
|
||
// AssertEqualsYAML compares a YAML string to the golden file. Data is | ||
// noramlized before comparing so data which is formatted differently but | ||
// semantically equivalent will not fail. | ||
func (g *Gold) AssertEqualsYAML(goldenPath, actual string) { | ||
g.t.Helper() | ||
g.verify(g.assert(goldenPath, actual, formatting.YAML)) | ||
} | ||
|
||
// AssertEquals compares a string to the contents of the golden file. If Gold | ||
// was configured with an update flag which is true then the golden file will | ||
// be created if it does not exist or overwritten with the supplied data if it | ||
// does. | ||
func (g *Gold) AssertEquals(goldenPath, actual string) { | ||
g.t.Helper() | ||
g.verify(g.assert(goldenPath, actual, formatting.NoOp)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"foo": "bar" | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |