github.com/kubri/kubri@v0.5.1-0.20240317001612-bda2aaef967e/internal/test/yaml.go (about)

     1  package test
     2  
     3  import (
     4  	"bytes"
     5  	"strings"
     6  
     7  	"github.com/MakeNowJust/heredoc/v2"
     8  )
     9  
    10  func YAML(s string) []byte {
    11  	return []byte(strings.ReplaceAll(heredoc.Doc(s), "\t", "  "))
    12  }
    13  
    14  func JoinYAML(s ...string) []byte {
    15  	b := make([][]byte, 0, len(s))
    16  	for _, v := range s {
    17  		b = append(b, YAML(v))
    18  	}
    19  	return bytes.Join(b, []byte("\n"))
    20  }