One environment string over 128 KiB made the container fail to start with no words; the gate reads --changed-file, and a command that cannot start now says its error.
32 lines
876 B
Go
32 lines
876 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestTheGateJudgesAFileOfPathsAsItDoesTheSameListOfThem(t *testing.T) { // 1247/AC3
|
|
paths := []string{"modules/a/x.go", "modules/a/y.go", "modules/b/z.go", "README.md"}
|
|
file := filepath.Join(t.TempDir(), "changed.txt")
|
|
if err := os.WriteFile(file, []byte(strings.Join(paths, "\n")+"\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fromFile, err := changedPaths("", file)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fromList, err := changedPaths(strings.Join(paths, ","), "")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !reflect.DeepEqual(fromFile, fromList) || len(fromFile) != len(paths) {
|
|
t.Errorf("the file gives %v, the list %v", fromFile, fromList)
|
|
}
|
|
if _, err := changedPaths("", filepath.Join(t.TempDir(), "none")); err == nil {
|
|
t.Error("a file that is not there is read as no paths")
|
|
}
|
|
}
|