github.com/fanux/shipyard@v0.0.0-20161009071005-6515ce223235/controller/mock_test/helpers.go (about)

     1  package mock_test
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/samalba/dockerclient"
     7  	"github.com/shipyard/shipyard"
     8  	"github.com/shipyard/shipyard/auth"
     9  	"github.com/shipyard/shipyard/dockerhub"
    10  	registry "github.com/shipyard/shipyard/registry/v1"
    11  )
    12  
    13  var (
    14  	TestContainerId    = "1234567890abcdefg"
    15  	TestContainerName  = "test-container"
    16  	TestContainerImage = "test-image"
    17  	TestRegistry       = &shipyard.Registry{
    18  		ID:   "0",
    19  		Name: "test-registry",
    20  		Addr: "http://localhost:5000",
    21  	}
    22  	TestRepository    = &registry.Repository{}
    23  	TestContainerInfo = &dockerclient.ContainerInfo{
    24  		Id:      TestContainerId,
    25  		Created: string(time.Now().UnixNano()),
    26  		Name:    TestContainerName,
    27  		Image:   TestContainerImage,
    28  	}
    29  	TestNode = &shipyard.Node{
    30  		ID:   "0",
    31  		Name: "testnode",
    32  		Addr: "tcp://127.0.0.1:3375",
    33  	}
    34  	TestAccount = &auth.Account{
    35  		ID:       "0",
    36  		Username: "testuser",
    37  		Password: "test",
    38  	}
    39  	TestEvent = &shipyard.Event{
    40  		Type:          "test-event",
    41  		ContainerInfo: TestContainerInfo,
    42  		Message:       "test message",
    43  		Tags:          []string{"test-tag"},
    44  	}
    45  	TestServiceKey = &auth.ServiceKey{
    46  		Key:         "test-key",
    47  		Description: "Test Key",
    48  	}
    49  	TestWebhookKey = &dockerhub.WebhookKey{
    50  		ID:    "1234",
    51  		Image: "ehazlett/test",
    52  		Key:   "abcdefg",
    53  	}
    54  	TestConsoleSession = &shipyard.ConsoleSession{
    55  		ID:          "0",
    56  		ContainerID: "abcdefg",
    57  		Token:       "1234567890",
    58  	}
    59  )
    60  
    61  func getTestContainerInfo(id string, name string, image string) *dockerclient.ContainerInfo {
    62  	return &dockerclient.ContainerInfo{
    63  		Id:      id,
    64  		Created: string(time.Now().UnixNano()),
    65  		Name:    name,
    66  		Image:   image,
    67  	}
    68  }
    69  
    70  func getTestContainers() []*dockerclient.ContainerInfo {
    71  	return []*dockerclient.ContainerInfo{
    72  		getTestContainerInfo(TestContainerId, TestContainerName, TestContainerImage),
    73  	}
    74  }
    75  
    76  func getTestEvents() []*shipyard.Event {
    77  	return []*shipyard.Event{
    78  		TestEvent,
    79  	}
    80  }