github.com/release-engineering/exodus-rsync@v1.11.2/internal/cmd/cmd_dryrun_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os"
     5  	"path"
     6  	"testing"
     7  
     8  	"github.com/golang/mock/gomock"
     9  	"github.com/release-engineering/exodus-rsync/internal/gw"
    10  )
    11  
    12  func TestMainDryRunSync(t *testing.T) {
    13  	wd, err := os.Getwd()
    14  	if err != nil {
    15  		t.Fatal(err)
    16  	}
    17  
    18  	SetConfig(t, CONFIG)
    19  	ctrl := MockController(t)
    20  
    21  	mockGw := gw.NewMockInterface(ctrl)
    22  	ext.gw = mockGw
    23  
    24  	client := FakeClient{blobs: make(map[string]string)}
    25  	mockGw.EXPECT().NewDryRunClient(gomock.Any(), EnvMatcher{"best-env"}).Return(&client, nil)
    26  
    27  	srcPath := path.Clean(wd + "/../../test/data/srctrees/just-files")
    28  
    29  	args := []string{
    30  		"rsync",
    31  		"--dry-run",
    32  		srcPath + "/",
    33  		"exodus:/some/target",
    34  	}
    35  
    36  	got := Main(args)
    37  
    38  	// It should complete successfully.
    39  	if got != 0 {
    40  		t.Error("returned incorrect exit code", got)
    41  	}
    42  
    43  }