File tree Expand file tree Collapse file tree 2 files changed +64
-30
lines changed Expand file tree Collapse file tree 2 files changed +64
-30
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,12 @@ import (
21
21
"fmt"
22
22
"io"
23
23
"math"
24
- "os"
25
24
"reflect"
26
25
"strings"
27
26
"time"
28
27
28
+ yaml "github.com/oasdiff/yaml3"
29
29
. "gopkg.in/check.v1"
30
- "github.com/oasdiff/yaml3"
31
30
)
32
31
33
32
var unmarshalIntTest = 123
@@ -1742,34 +1741,6 @@ func (s *S) TestFuzzCrashers(c *C) {
1742
1741
}
1743
1742
}
1744
1743
1745
- func (s * S ) TestLocation (c * C ) {
1746
- input := `paths:
1747
- /testpath:
1748
- get:
1749
- responses:
1750
- "200":
1751
- $ref: "#/components/responses/testpath_200_response"
1752
-
1753
- components:
1754
- responses:
1755
- testpath_200_response:
1756
- description: a custom response
1757
- content:
1758
- application/json:
1759
- schema:
1760
- type: string
1761
- `
1762
- dec := yaml .NewDecoder (bytes .NewBufferString (input ))
1763
- dec .Origin (false )
1764
- var out any
1765
- err := dec .Decode (& out )
1766
- c .Assert (err , IsNil )
1767
- result , err := yaml .Marshal (out )
1768
- c .Assert (err , IsNil )
1769
- fo , _ := os .Create ("output.yaml" )
1770
- fo .Write (result )
1771
- }
1772
-
1773
1744
//var data []byte
1774
1745
//func init() {
1775
1746
// var err error
Original file line number Diff line number Diff line change
1
+ package yaml_test
2
+
3
+ import (
4
+ "bytes"
5
+
6
+ yaml "github.com/oasdiff/yaml3"
7
+ . "gopkg.in/check.v1"
8
+ )
9
+
10
+ func (s * S ) TestOrigin_Disabled (c * C ) {
11
+ input := `
12
+ root:
13
+ hello: world
14
+ `
15
+
16
+ dec := yaml .NewDecoder (bytes .NewBufferString (input [1 :]))
17
+ dec .Origin (false )
18
+ var out any
19
+ err := dec .Decode (& out )
20
+ c .Assert (err , IsNil )
21
+ result , err := yaml .Marshal (out )
22
+ c .Assert (err , IsNil )
23
+
24
+ buf := new (bytes.Buffer )
25
+ buf .Write (result )
26
+
27
+ c .Assert (buf .String (), Equals , input [1 :])
28
+ }
29
+
30
+ func (s * S ) TestOrigin_Enabled (c * C ) {
31
+ input := `
32
+ root:
33
+ hello: world
34
+ `
35
+
36
+ dec := yaml .NewDecoder (bytes .NewBufferString (input [1 :]))
37
+ dec .Origin (true )
38
+ var out any
39
+ err := dec .Decode (& out )
40
+ c .Assert (err , IsNil )
41
+ result , err := yaml .Marshal (out )
42
+ c .Assert (err , IsNil )
43
+
44
+ buf := new (bytes.Buffer )
45
+ buf .Write (result )
46
+
47
+ output := `
48
+ root:
49
+ hello: world
50
+ origin:
51
+ fields:
52
+ hello:
53
+ column: 5
54
+ line: 2
55
+ name: hello
56
+ key:
57
+ column: 1
58
+ line: 1
59
+ name: root
60
+ `
61
+
62
+ c .Assert (buf .String (), Equals , output [1 :])
63
+ }
You can’t perform that action at this time.
0 commit comments