github.com/pachyderm/pachyderm@v1.13.4/src/server/pfs/cmds/cmds_test.go (about) 1 package cmds 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/pachyderm/pachyderm/src/client/pkg/require" 8 "github.com/pachyderm/pachyderm/src/server/pfs/fuse" 9 tu "github.com/pachyderm/pachyderm/src/server/pkg/testutil" 10 ) 11 12 func TestCommit(t *testing.T) { 13 if testing.Short() { 14 t.Skip("Skipping integration tests in short mode") 15 } 16 require.NoError(t, tu.BashCmd(` 17 pachctl create repo {{.repo}} 18 19 # Create a commit and put some data in it 20 commit1=$(pachctl start commit {{.repo}}@master) 21 echo "file contents" | pachctl put file {{.repo}}@${commit1}:/file -f - 22 pachctl finish commit {{.repo}}@${commit1} 23 24 # Check that the commit above now appears in the output 25 pachctl list commit {{.repo}} \ 26 | match ${commit1} 27 28 # Create a second commit and put some data in it 29 commit2=$(pachctl start commit {{.repo}}@master) 30 echo "file contents" | pachctl put file {{.repo}}@${commit2}:/file -f - 31 pachctl finish commit {{.repo}}@${commit2} 32 33 # Check that the commit above now appears in the output 34 pachctl list commit {{.repo}} \ 35 | match ${commit1} \ 36 | match ${commit2} 37 `, 38 "repo", tu.UniqueString("TestCommit-repo"), 39 ).Run()) 40 } 41 42 func TestPutFileSplit(t *testing.T) { 43 if testing.Short() { 44 t.Skip("Skipping integration tests in short mode") 45 } 46 require.NoError(t, tu.BashCmd(` 47 pachctl create repo {{.repo}} 48 49 pachctl put file {{.repo}}@master:/data --split=csv --header-records=1 <<EOF 50 name,job 51 alice,accountant 52 bob,baker 53 EOF 54 55 pachctl get file "{{.repo}}@master:/data/*0" \ 56 | match "name,job" 57 pachctl get file "{{.repo}}@master:/data/*0" \ 58 | match "alice,accountant" 59 pachctl get file "{{.repo}}@master:/data/*0" \ 60 | match -v "bob,baker" 61 62 pachctl get file "{{.repo}}@master:/data/*1" \ 63 | match "name,job" 64 pachctl get file "{{.repo}}@master:/data/*1" \ 65 | match "bob,baker" 66 pachctl get file "{{.repo}}@master:/data/*1" \ 67 | match -v "alice,accountant" 68 69 pachctl get file "{{.repo}}@master:/data/*" \ 70 | match "name,job" 71 pachctl get file "{{.repo}}@master:/data/*" \ 72 | match "alice,accountant" 73 pachctl get file "{{.repo}}@master:/data/*" \ 74 | match "bob,baker" 75 `, 76 "repo", tu.UniqueString("TestPutFileSplit-repo"), 77 ).Run()) 78 } 79 80 func TestMountParsing(t *testing.T) { 81 if testing.Short() { 82 t.Skip("Skipping integration tests in short mode") 83 } 84 expected := map[string]*fuse.RepoOptions{ 85 "repo1": { 86 Branch: "branch", 87 Write: true, 88 }, 89 "repo2": { 90 Branch: "master", 91 Write: true, 92 }, 93 "repo3": { 94 Branch: "master", 95 }, 96 } 97 opts, err := parseRepoOpts([]string{"repo1@branch+w", "repo2+w", "repo3"}) 98 require.NoError(t, err) 99 require.Equal(t, 3, len(opts)) 100 fmt.Printf("%+v\n", opts) 101 for repo, ro := range expected { 102 require.Equal(t, ro, opts[repo]) 103 } 104 }