}
user, uid, group, gid := ft.CurrentUserAndGroup()
+ skipUnlessCiRun := len(os.Getenv("SAFCM_CI_RUN")) == 0
+
tmpTestFilePath := "/tmp/safcm-sync-files-test-file"
tests := []struct {
name string
+ skip bool
req safcm.MsgSyncReq
prepare func()
triggers []string
{
"basic: create",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
{
"basic: no change",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
{
"invalid File: user",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
},
{
"invalid File: group",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
// Use numeric IDs as not all systems use root/root;
// for example BSDs use root/wheel.
"absolute paths: no change",
+ skipUnlessCiRun,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
"/": {
{
"triggers: no change",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
{
"triggers: change root",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
{
"triggers: change middle",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
{
"triggers: change leaf",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
{
"triggers: multiple changes",
+ false,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
".": {
{
"triggers: absolute paths",
+ skipUnlessCiRun,
safcm.MsgSyncReq{
Files: map[string]*safcm.File{
"/": {
},
},
},
- func() {
- // This is slightly racy but the file name
- // should be rare enough that this isn't an
- // issue
- _, err := os.Stat(tmpTestFilePath)
- if err == nil {
- t.Fatalf("%q exists, aborting",
- tmpTestFilePath)
- }
- },
+ nil,
[]string{
"/",
"/tmp",
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
+ if tc.skip {
+ t.SkipNow()
+ }
+
// Create separate test directory for each test case
path := filepath.Join(cwd, "testdata", "files-"+tc.name)
err = os.Mkdir(path, 0700)