-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hi 👋
Depending on how an InputFile is created the amount of Documents differ for the same file/data. I would have expected no diff.
I ran the example program below with an empty file called example.txt in the same folder. I got the following output:
failed to compare input: comparing YAMLs with a different number of documents is currently not supported
expected len: 1
actual len: 0
expected file value: ''package main
import (
"fmt"
"github.com/gonvenience/ytbx"
"github.com/homeport/dyff/pkg/dyff"
"os"
)
func main() {
filename := "empty.txt"
expectedFile, err := ytbx.LoadFile(filename)
if err != nil {
fmt.Errorf("failed to load expected: %v", err)
os.Exit(1)
}
data, err := os.ReadFile(filename)
docs, err := ytbx.LoadYAMLDocuments(data)
if err != nil {
fmt.Printf("failed to load actual: %v", err)
os.Exit(1)
}
actualFile := ytbx.InputFile{
Documents: docs,
}
_, err = dyff.CompareInputFiles(expectedFile, actualFile, dyff.KubernetesEntityDetection(true))
if err != nil {
fmt.Printf("failed to compare input: %v\n", err)
fmt.Printf("expected len: %d\n", len(expectedFile.Documents))
fmt.Printf("actual len: %d\n", len(actualFile.Documents))
fmt.Printf("expected file value: '%s'\n", expectedFile.Documents[0].Value)
os.Exit(1)
}
}Metadata
Metadata
Assignees
Labels
No labels