Skip to content

Instantly share code, notes, and snippets.

@lusis
Created January 9, 2018 07:24
Show Gist options
  • Save lusis/33d7b2ee3d9def95b3cb1c8b330c92c3 to your computer and use it in GitHub Desktop.
Save lusis/33d7b2ee3d9def95b3cb1c8b330c92c3 to your computer and use it in GitHub Desktop.
two-pass but it's only in testing
func TestSCMPluginForProjectResponseEnableImport(t *testing.T) {
obj := &SCMPluginForProjectResponse{}
// The test response file used here does NOT match the struct
data, dataErr := testdata.GetBytes(ListSCMPluginsResponseExportTestFile)
if dataErr != nil {
t.Fatalf(dataErr.Error())
}
placeholder := make(map[string]interface{})
_ = json.Unmarshal(data, &placeholder)
//err := obj.FromBytes(data)
decoder, newErr := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
ErrorUnused: true,
WeaklyTypedInput: false,
Result: obj,
TagName: "json",
})
assert.NoError(t, newErr)
dErr := decoder.Decode(placeholder)
if dErr != nil {
t.Fatalf(dErr.Error())
}
assert.Implements(t, (*VersionedResponse)(nil), obj)
//assert.NotNil(t, obj)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment