mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-23 00:38:26 +00:00
4177fddcc4
This change imports the modifying runtime abstraction from the experimental branch. This encapsulates the checks for whether modification is required, and forwards the loaded spec to the specified modifier. This allows for the same code to be reused when performing more complex modifications. Signed-off-by: Evan Lezar <elezar@nvidia.com>
40 lines
806 B
Go
40 lines
806 B
Go
package oci
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/test"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMaintainSpec(t *testing.T) {
|
|
moduleRoot, err := test.GetModuleRoot()
|
|
require.NoError(t, err)
|
|
|
|
files := []string{
|
|
"config.clone3.json",
|
|
}
|
|
|
|
for _, f := range files {
|
|
inputSpecPath := filepath.Join(moduleRoot, "test/input", f)
|
|
|
|
spec := NewFileSpec(inputSpecPath).(*fileSpec)
|
|
|
|
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))
|
|
}
|
|
}
|