This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
forked from datacontract/datacontract-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inline_test.go
86 lines (84 loc) · 1.8 KB
/
inline_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package datacontract
import (
"bytes"
"testing"
)
func TestInline(t *testing.T) {
type args struct {
dataContractLocation string
}
tests := []LogOutputTest[args]{
{
name: "quality",
args: args{dataContractLocation: "test_resources/inline/quality_datacontract.yaml"},
wantErr: false,
wantOutput: `dataContractSpecification: 0.9.2
id: my-data-contract-id
info:
title: My Data Contract
version: 0.0.1
quality:
specification: |
checks for my_table:
- duplicate_count(order_id) = 0
type: SodaCL
`,
},
{
name: "schema",
args: args{dataContractLocation: "test_resources/inline/schema_datacontract.yaml"},
wantErr: false,
wantOutput: `dataContractSpecification: 0.9.2
id: my-data-contract-id
info:
title: My Data Contract
version: 0.0.1
schema:
specification: |
version: 2
models:
- name: my_table
description: "contains data"
config:
materialized: table
columns:
- name: my_column
data_type: text
description: "contains values"
type: dbt
`,
},
{
name: "models",
args: args{dataContractLocation: "test_resources/inline/models_datacontract.yaml"},
wantErr: false,
wantOutput: `dataContractSpecification: 0.9.2
definitions:
my_table:
description: contains data
fields:
my_column:
description: contains values
type: text
type: table
id: my-data-contract-id
info:
title: My Data Contract
version: 0.0.1
models:
my_table:
description: contains data
fields:
my_column:
description: contains values
type: text
type: table
`,
},
}
for _, tt := range tests {
RunLogOutputTest(t, tt, "Inline", func(buffer *bytes.Buffer) error {
return Inline(tt.args.dataContractLocation, buffer)
})
}
}