37 lines
960 B
Go
37 lines
960 B
Go
package nixbuild_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.gensokyo.uk/yonah/nixbuild"
|
|
)
|
|
|
|
func TestCollectFromDerivations(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
show []byte
|
|
want string
|
|
}{
|
|
{"getchoo atlas", getchooAtlasShow, getchooAtlasCollective},
|
|
{"getchoo glados", getchooGladosShow, getchooGladosCollective},
|
|
{"pluiedev pappardelle", pluiedevPappardelleShow, pluiedevPappardelleCollective},
|
|
}
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
var derivations nixbuild.DerivationMap
|
|
if err := json.Unmarshal(tc.show, &derivations); err != nil {
|
|
t.Fatalf("cannot unmarshal test data: %v", err)
|
|
}
|
|
got := nixbuild.CollectFromDerivations(derivations)
|
|
want := strings.Split(strings.TrimSpace(tc.want), "\n")
|
|
if !slices.Equal(got, want) {
|
|
t.Errorf("CollectFromDerivations:\n%s, want\n%s",
|
|
strings.Join(got, "\n"), strings.Join(want, "\n"))
|
|
}
|
|
})
|
|
}
|
|
}
|