2021-11-04 12:42:21 +00:00
|
|
|
package oci
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2023-12-01 01:10:10 +00:00
|
|
|
|
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/test"
|
2021-11-04 12:42:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
2023-08-25 14:48:11 +00:00
|
|
|
_, err := spec.Load()
|
|
|
|
require.NoError(t, err)
|
2021-11-04 12:42:21 +00:00
|
|
|
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
}
|