github.com/jgrancell/metasync@v0.0.0-20220105143315-c43793d9d9c1/app/app_test.go (about) 1 package app 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/jgrancell/metasync/configuration" 8 ) 9 10 func TestSyncSubcommand(t *testing.T) { 11 pwd, _ := os.Getwd() 12 13 os.Chdir("../testdata") 14 c := &configuration.Configuration{ 15 ConfigurationPath: ".metasync.yml", 16 } 17 c.Load() 18 os.Chdir(pwd) 19 20 a := &App{ 21 Configuration: c, 22 Dryrun: true, 23 Subcommand: "sync", 24 } 25 26 if a.Run() != 0 { 27 t.Errorf("sync subcommand failed with exit code 1, expected 0") 28 } 29 } 30 31 func TestNonexistantSubcommand(t *testing.T) { 32 a := &App{} 33 34 if a.Run() == 0 { 35 t.Errorf("sync subcommand erroneously succeeded with exit code 0, expected 1") 36 } 37 }