-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathput_test.go
72 lines (61 loc) · 1.65 KB
/
put_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
// Copyright 2015 MediaMath <http://www.mediamath.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import (
"testing"
"time"
)
func TestUrlEncodingDoesGroupPaths(t *testing.T) {
loc := &location{
host: "https://example.com",
repo: "repo1",
group: "com.mediamath",
artifact: "foo",
version: "121-SNAPSHOT",
file: "foo.zip",
}
if loc.URL() != "https://example.com/repo1/com/mediamath/foo/121-SNAPSHOT/foo.zip" {
t.Errorf(loc.URL())
}
}
func TestUrlEncodingOnlyFileName(t *testing.T) {
loc := &location{
host: "https://example.com",
repo: "repo1",
group: "com.mediamath",
artifact: "foo",
version: "121-SNAPSHOT",
file: "moo/bar/goo/foo.zip",
}
if loc.URL() != "https://example.com/repo1/com/mediamath/foo/121-SNAPSHOT/foo.zip" {
t.Errorf(loc.URL())
}
}
func TestUrlEncodingStripsHostIfNecessary(t *testing.T) {
loc := &location{
host: "https://example.com/",
repo: "repo1",
group: "com.mediamath",
artifact: "foo",
version: "121-SNAPSHOT",
file: "moo/bar/goo/foo.zip",
}
if loc.URL() != "https://example.com/repo1/com/mediamath/foo/121-SNAPSHOT/foo.zip" {
t.Errorf(loc.URL())
}
}
func TestDeployNonExistantFileIsErrorNotPanic(t *testing.T) {
loc := &location{
host: "https://artifactory.mediamath.com/artifactory",
repo: "libs-release-global",
group: "com.mediamath",
artifact: "part",
version: "failing-test",
file: "doesntexist",
}
resp := deploy(30*time.Second, loc)
if resp.PublishError == nil {
t.Errorf("Should have error: %v", resp)
}
}