|
@@ -15,6 +15,7 @@ import (
|
|
|
"github.com/aws/aws-sdk-go/aws/request"
|
|
|
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
|
|
|
"github.com/docker/docker/daemon/logger"
|
|
|
+ "github.com/docker/docker/daemon/logger/loggerutils"
|
|
|
"github.com/docker/docker/dockerversion"
|
|
|
)
|
|
|
|
|
@@ -691,3 +692,33 @@ func TestCollectBatchWithDuplicateTimestamps(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestCreateTagSuccess(t *testing.T) {
|
|
|
+ mockClient := newMockClient()
|
|
|
+ ctx := logger.Context{
|
|
|
+ ContainerName: "/test-container",
|
|
|
+ ContainerID: "container-abcdefghijklmnopqrstuvwxyz01234567890",
|
|
|
+ Config: map[string]string{"tag": "{{.Name}}/{{.FullID}}"},
|
|
|
+ }
|
|
|
+ logStreamName, e := loggerutils.ParseLogTag(ctx, loggerutils.DefaultTemplate)
|
|
|
+ if e != nil {
|
|
|
+ t.Errorf("Error generating tag: %q", e)
|
|
|
+ }
|
|
|
+ stream := &logStream{
|
|
|
+ client: mockClient,
|
|
|
+ logGroupName: groupName,
|
|
|
+ logStreamName: logStreamName,
|
|
|
+ }
|
|
|
+ mockClient.createLogStreamResult <- &createLogStreamResult{}
|
|
|
+
|
|
|
+ err := stream.create()
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Received unexpected err: %v\n", err)
|
|
|
+ }
|
|
|
+ argument := <-mockClient.createLogStreamArgument
|
|
|
+
|
|
|
+ if *argument.LogStreamName != "test-container/container-abcdefghijklmnopqrstuvwxyz01234567890" {
|
|
|
+ t.Errorf("Expected LogStreamName to be %s", "test-container/container-abcdefghijklmnopqrstuvwxyz01234567890")
|
|
|
+ }
|
|
|
+}
|