Skip to content

Commit

Permalink
Test directory artifact paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoo1 committed Mar 11, 2022
1 parent 40e88f4 commit b935ccf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
23 changes: 20 additions & 3 deletions agent/artifact_uploader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,29 @@ func TestCollect(t *testing.T) {
FileSize: 2038453,
Sha1Sum: "bd4caf2e01e59777744ac1d52deafa01c2cb9bfd",
},
{
Name: "output.log",
Path: []string{rootWithoutVolume[1:], "test", "fixtures", "artifacts", "nested", "output.log"},
AbsolutePath: filepath.Join(root, "test", "fixtures", "artifacts", "nested", "output.log"),
GlobPath: filepath.Join("test", "fixtures", "artifacts", "nested"),
FileSize: 14,
Sha1Sum: "1ec2e13e3871a980eaee0f11c6f47ad1d1f97b3e",
},
{
Name: "logfile.out",
Path: []string{rootWithoutVolume[1:], "test", "fixtures", "artifacts", "nested", "nested0", "logfile.out"},
AbsolutePath: filepath.Join(root, "test", "fixtures", "artifacts", "nested", "nested0", "logfile.out"),
GlobPath: filepath.Join("test", "fixtures", "artifacts", "nested"),
FileSize: 19,
Sha1Sum: "e30f8100faed6430e6fd617da8ea17100ac97188",
},
}

uploader := NewArtifactUploader(logger.Discard, nil, ArtifactUploaderConfig{
Paths: fmt.Sprintf("%s;%s",
Paths: fmt.Sprintf("%s;%s;%s",
filepath.Join("test", "fixtures", "artifacts", "**/*.jpg"),
filepath.Join(root, "test", "fixtures", "artifacts", "**/*.gif"),
filepath.Join("test", "fixtures", "artifacts", "nested"),
),
})

Expand Down Expand Up @@ -109,14 +126,14 @@ func TestCollect(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 5, len(artifactsWithoutExperimentEnabled))
assert.Equal(t, 7, len(artifactsWithoutExperimentEnabled))

experiments.Enable(`normalised-upload-paths`)
artifactsWithExperimentEnabled, err := uploader.Collect()
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 5, len(artifactsWithExperimentEnabled))
assert.Equal(t, 7, len(artifactsWithExperimentEnabled))

// These test cases use filepath.Join, which uses per-OS path separators;
// this is the behaviour without normalised-upload-paths.
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/artifacts/nested/nested0/logfile.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logging out to file
1 change: 1 addition & 0 deletions test/fixtures/artifacts/nested/output.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logging output

0 comments on commit b935ccf

Please sign in to comment.