@@ -17,6 +17,7 @@ import (
17
17
"github.com/stretchr/testify/require"
18
18
19
19
"github.com/nobl9/nobl9-go/manifest"
20
+ "github.com/nobl9/nobl9-go/manifest/v1alpha/dataexport"
20
21
)
21
22
22
23
//go:embed test_data/reader
@@ -143,6 +144,27 @@ func TestReadDefinitions_FromReader(t *testing.T) {
143
144
})
144
145
}
145
146
147
+ func TestReadDefinitions_UsingCustomizedUnmarshal (t * testing.T ) {
148
+ t .Run ("report an error when unexpected structure was returned" , func (t * testing.T ) {
149
+ definitions , err := ReadObjectsFromSources (
150
+ context .Background (),
151
+ NewObjectSourceReader (readTestFile (t , "dataexport.yaml" ), "stdin" ))
152
+ require .NoError (t , err )
153
+
154
+ definitionsMatchExpected (t , definitions , expectedMeta {Name : "dataexport" , ManifestSrc : "stdin" })
155
+
156
+ require .IsType (t , dataexport.DataExport {}, definitions [0 ])
157
+ assert .Equal (
158
+ t ,
159
+ definitions [0 ].(dataexport.DataExport ).Spec .Spec ,
160
+ dataexport.S3DataExportSpec {
161
+ BucketName : "example-bucket" ,
162
+ RoleARN : "arn:aws:iam::341861879477:role/n9-access" ,
163
+ },
164
+ )
165
+ })
166
+ }
167
+
146
168
func TestReadDefinitions_FromURL (t * testing.T ) {
147
169
t .Run ("successful definitions GET for http scheme" , func (t * testing.T ) {
148
170
srv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
@@ -279,6 +301,7 @@ func TestReadDefinitions_FromFS(t *testing.T) {
279
301
{Name : "service_and_agent" , ManifestSrc : workingDir ("test_data/reader/inputs/service_and_agent.yaml" )},
280
302
{Name : "projects_and_direct" , ManifestSrc : workingDir ("test_data/reader/inputs/projects_and_direct.yml" )},
281
303
{Name : "annotations" , ManifestSrc : workingDir ("test_data/reader/inputs/annotations.yaml" )},
304
+ {Name : "dataexport" , ManifestSrc : workingDir ("test_data/reader/inputs/dataexport.yaml" )},
282
305
{Name : "project" , ManifestSrc : workingDir ("test_data/reader/inputs/project.json" )},
283
306
}
284
307
0 commit comments