MCPcopy Create free account
hub / github.com/conforma/cli / TestWriterWithCustomSettings

Function TestWriterWithCustomSettings

internal/validate/vsa/vsa_test.go:735–769  ·  view source on GitHub ↗

TestWriterWithCustomSettings tests Writer with custom filesystem and settings

(t *testing.T)

Source from the content-addressed store, hash-verified

733
734// TestWriterWithCustomSettings tests Writer with custom filesystem and settings
735func TestWriterWithCustomSettings(t *testing.T) {
736 // Create custom writer with different settings
737 fs := afero.NewMemMapFs()
738 writer := &Writer{
739 FS: fs,
740 TempDirPrefix: "custom-vsa-",
741 FilePerm: 0o644,
742 }
743
744 // Create test predicate
745 pred := &Predicate{
746 ImageRefs: []string{"test-image:tag"},
747 Timestamp: "2024-03-21T12:00:00Z",
748 Verifier: "ec-cli",
749 PolicySource: "test-policy",
750 Summary: VSASummary{
751 Component: ComponentSummary{
752 Name: "test-component",
753 ContainerImage: "test-image:tag",
754 },
755 },
756 }
757
758 // Write predicate
759 vsaPath, err := writer.WritePredicate(pred)
760 require.NoError(t, err)
761
762 // Verify custom settings were used
763 assert.Contains(t, vsaPath, "custom-vsa-")
764
765 // Verify file was written to custom filesystem
766 exists, err := afero.Exists(fs, vsaPath)
767 assert.NoError(t, err)
768 assert.True(t, exists)
769}
770
771// TestWriterErrorHandling tests Writer error handling scenarios
772func TestWriterErrorHandling(t *testing.T) {

Callers

nothing calls this directly

Calls 1

WritePredicateMethod · 0.95

Tested by

no test coverage detected