-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a separate method for creating Adaptation Sets with IDs (#46)
* Make separate methods for creating Adaptation Sets with IDs * Revert ordering of Representation attributes and structure AdaptationSet in the standard golang way * Added generate step and regenerated fixtures
- Loading branch information
Showing
14 changed files
with
321 additions
and
172 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,6 @@ examples-live: | |
|
||
examples-ondemand: | ||
go run examples/ondemand.go | ||
|
||
generate: | ||
GENERATE_FIXTURES=true $(MAKE) test |
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 |
---|---|---|
@@ -1,43 +1,29 @@ | ||
package testfixtures | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"io/ioutil" | ||
) | ||
|
||
func LoadJSONFixture(path string, uo interface{}) (js string, fjs string) { | ||
// Load in the file and store in a string | ||
f, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
panic(fmt.Sprintf("LoadJSONFixture Error. ioutil.ReadFile. path = %s, Err = %s", path, err.Error())) | ||
} | ||
js = string(f) | ||
|
||
// Generate the flat(compacted) JSON | ||
cb := new(bytes.Buffer) | ||
err = json.Compact(cb, f) | ||
if err != nil { | ||
panic(fmt.Sprintf("LoadJSONFixture Error. json.Compact. path = %s, Err = %s", path, err.Error())) | ||
} | ||
fjs = cb.String() | ||
"os" | ||
"testing" | ||
|
||
// Unmarshal the JSON to an object | ||
err = json.Unmarshal(f, &uo) | ||
if err != nil { | ||
panic(fmt.Sprintf("LoadJSONFixture Error. json.Unmarshal. path = %s, Err = %s", path, err.Error())) | ||
} | ||
|
||
return | ||
} | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// Load test fixture from path relative to fixtures directory | ||
func LoadFixture(path string) (js string) { | ||
f, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
panic(fmt.Sprintf("LoadFixture Error. ioutil.ReadFile. path = %s, Err = %s", path, err.Error())) | ||
} | ||
js = string(f) | ||
return | ||
return string(f) | ||
} | ||
|
||
func CompareFixture(t *testing.T, fixturePath string, actualContent string) { | ||
expectedContent := LoadFixture(fixturePath) | ||
if os.Getenv("GENERATE_FIXTURES") != "" { | ||
ioutil.WriteFile(fixturePath, []byte(actualContent), os.ModePerm) | ||
fmt.Println("Wrote fixture: " + fixturePath) | ||
} else { | ||
require.Equal(t, expectedContent, actualContent) | ||
} | ||
} |
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
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
Oops, something went wrong.