2021-11-04 12:42:21 +00:00
|
|
|
package oci
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2022-03-10 11:37:08 +00:00
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/test"
|
2021-11-04 12:42:21 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMaintainSpec(t *testing.T) {
|
2022-03-10 11:37:08 +00:00
|
|
|
moduleRoot, err := test.GetModuleRoot()
|
2021-11-04 12:42:21 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
files := []string{
|
|
|
|
"config.clone3.json",
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, f := range files {
|
|
|
|
inputSpecPath := filepath.Join(moduleRoot, "test/input", f)
|
|
|
|
|
2022-01-31 14:11:36 +00:00
|
|
|
spec := NewFileSpec(inputSpecPath).(*fileSpec)
|
2021-11-04 12:42:21 +00:00
|
|
|
|
|
|
|
spec.Load()
|
|
|
|
|
|
|
|
outputSpecPath := filepath.Join(moduleRoot, "test/output", f)
|
|
|
|
spec.path = outputSpecPath
|
|
|
|
spec.Flush()
|
|
|
|
|
|
|
|
inputContents, err := os.ReadFile(inputSpecPath)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
outputContents, err := os.ReadFile(outputSpecPath)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.JSONEq(t, string(inputContents), string(outputContents))
|
|
|
|
}
|
|
|
|
}
|