-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtxtar_test.go
34 lines (29 loc) · 918 Bytes
/
txtar_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
// Copyright (c) 2023 Volvo Car Corporation
// SPDX-License-Identifier: Apache-2.0
package kubeutil
import (
"os"
"testing"
tu "github.com/golingon/lingon/pkg/testutil"
"golang.org/x/tools/txtar"
)
func TestTxtar2YAML(t *testing.T) {
a, err := os.ReadFile("testdata/apps.txt")
tu.AssertNoError(t, err, "reading txtar file")
ar := txtar.Parse(a)
ay, err := os.ReadFile("testdata/apps.yaml")
tu.AssertNoError(t, err, "reading yaml file")
ar2y := Txtar2YAML(ar)
tu.AssertEqual(t, string(ay), string(ar2y))
}
func TestTxtar2JSON(t *testing.T) {
a, err := os.ReadFile("testdata/apps.txt")
tu.AssertNoError(t, err, "reading txtar file")
ar := txtar.Parse(a)
ar, err = TxtarYAML2TxtarJSON(ar)
tu.AssertNoError(t, err, "converting to json")
aj, err := os.ReadFile("testdata/apps.json")
tu.AssertNoError(t, err, "reading json file")
ar2j := Txtar2JSON(ar)
tu.AssertEqual(t, string(aj), string(ar2j))
}