/usr/share/gocode/src/github.com/hashicorp/atlas-go/v1/application_test.go is in golang-github-hashicorp-atlas-go-dev 0.0~git20151216.84.b66e377-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | package atlas
import (
"bytes"
"testing"
)
func TestSlug_returnsSlug(t *testing.T) {
app := &App{
User: "hashicorp",
Name: "project",
}
expected := "hashicorp/project"
if app.Slug() != expected {
t.Fatalf("expected %q to be %q", app.Slug(), expected)
}
}
func TestApp_fetchesApp(t *testing.T) {
server := newTestAtlasServer(t)
defer server.Stop()
client, err := NewClient(server.URL.String())
if err != nil {
t.Fatal(err)
}
app, err := client.App("hashicorp", "existing")
if err != nil {
t.Fatal(err)
}
if app.User != "hashicorp" {
t.Errorf("expected %q to be %q", app.User, "hashicorp")
}
if app.Name != "existing" {
t.Errorf("expected %q to be %q", app.Name, "existing")
}
}
func TestApp_returnsErrorNoApp(t *testing.T) {
server := newTestAtlasServer(t)
defer server.Stop()
client, err := NewClient(server.URL.String())
if err != nil {
t.Fatal(err)
}
_, err = client.App("hashicorp", "newproject")
if err == nil {
t.Fatal("expected error, but nothing was returned")
}
}
func TestCreateApp_createsAndReturnsApp(t *testing.T) {
server := newTestAtlasServer(t)
defer server.Stop()
client, err := NewClient(server.URL.String())
if err != nil {
t.Fatal(err)
}
app, err := client.CreateApp("hashicorp", "newproject")
if err != nil {
t.Fatal(err)
}
if app.User != "hashicorp" {
t.Errorf("expected %q to be %q", app.User, "hashicorp")
}
if app.Name != "newproject" {
t.Errorf("expected %q to be %q", app.Name, "newproject")
}
}
func TestCreateApp_returnsErrorExistingApp(t *testing.T) {
server := newTestAtlasServer(t)
defer server.Stop()
client, err := NewClient(server.URL.String())
if err != nil {
t.Fatal(err)
}
_, err = client.CreateApp("hashicorp", "existing")
if err == nil {
t.Fatal("expected error, but nothing was returned")
}
}
func TestUploadApp_createsAndReturnsVersion(t *testing.T) {
server := newTestAtlasServer(t)
defer server.Stop()
client, err := NewClient(server.URL.String())
if err != nil {
t.Fatal(err)
}
app := &App{
User: "hashicorp",
Name: "existing",
}
metadata := map[string]interface{}{"testing": true}
data := new(bytes.Buffer)
version, err := client.UploadApp(app, metadata, data, int64(data.Len()))
if err != nil {
t.Fatal(err)
}
if version != 125 {
t.Fatalf("bad: %#v", version)
}
}
|