Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pkg tests #76

Merged
merged 2 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cft/pkg/pkg_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build func_test
//go:build func_test

package pkg_test

Expand Down Expand Up @@ -211,8 +211,8 @@ func TestWrappedTypes(t *testing.T) {
propName string
expected interface{}
}{
{"AWS::Serverless::Function", "CodeURI", s3ZipURI},
{"AWS::Serverless::Api", "DefinitionURI", s3URI},
{"AWS::Serverless::Function", "CodeUri", s3ZipURI},
{"AWS::Serverless::Api", "DefinitionUri", s3URI},
{"AWS::AppSync::GraphQLSchema", "DefinitionS3Location", s3URI},
{"AWS::AppSync::Resolver", "RequestMappingTemplateS3Location", s3URI},
{"AWS::AppSync::Resolver", "ResponseMappingTemplateS3Location", s3URI},
Expand All @@ -221,7 +221,7 @@ func TestWrappedTypes(t *testing.T) {
{"AWS::ServerlessRepo::Application", "ReadmeUrl", s3URI},
{"AWS::ServerlessRepo::Application", "LicenseUrl", s3URI},
{"AWS::Glue::Job", "Command/ScriptLocation", s3URI},
{"AWS::Serverless::LayerVersion", "ContentURI", s3ZipURI},
{"AWS::Serverless::LayerVersion", "ContentUri", s3ZipURI},
{"AWS::Serverless::Application", "Location", httpURI},
{"AWS::Lambda::Function", "Code", map[string]interface{}{"S3Bucket": bucket, "S3Key": zipHash}},
{"AWS::ElasticBeanstalk::ApplicationVersion", "SourceBundle", map[string]interface{}{"S3Bucket": bucket, "S3Key": hash}},
Expand Down
20 changes: 13 additions & 7 deletions cft/pkg/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,33 @@ func upload(root, path string, force bool) (*s3Path, error) {
}
}

if result, ok := uploads[path]; ok {
artifactName := path
if force {
artifactName = "zip:" + artifactName
}

if result, ok := uploads[artifactName]; ok {
config.Debugf("Using existing upload for: %s\n", path)
return result, nil
}

config.Debugf("Uploading: %s\n", path)

info, err := os.Stat(path)
if err != nil {
return nil, err
}

origPath := path
if info.IsDir() || force {
// Zip it!
path, err = zipPath(path)
zipped, err := zipPath(path)
if err != nil {
return nil, err
}
config.Debugf("Zipped %s as %s\n", path, zipped)
path = zipped
}

config.Debugf("Uploading: %s\n", path)

content, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
Expand All @@ -146,13 +152,13 @@ func upload(root, path string, force bool) (*s3Path, error) {
bucket := s3.RainBucket(false)
key, err := s3.Upload(bucket, content)

uploads[origPath] = &s3Path{
uploads[artifactName] = &s3Path{
bucket: bucket,
key: key,
region: aws.Config().Region,
}

return uploads[origPath], err
return uploads[artifactName], err
}

func expectString(n *yaml.Node) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion cft/spec/internal/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build ignore
//go:build ignore

package main

Expand Down
2 changes: 1 addition & 1 deletion internal/aws/aws.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build !func_test
//go:build !func_test

// Package aws contains functionality that wraps the AWS SDK
package aws
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/cfn/cfn.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build !func_test
//go:build !func_test

package cfn

Expand Down
2 changes: 1 addition & 1 deletion internal/aws/cfn/mock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build func_test
//go:build func_test

package cfn

Expand Down
2 changes: 1 addition & 1 deletion internal/aws/ec2/ec2.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build !func_test
//go:build !func_test

package ec2

Expand Down
2 changes: 1 addition & 1 deletion internal/aws/ec2/mock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build func_test
//go:build func_test

package ec2

Expand Down
2 changes: 1 addition & 1 deletion internal/aws/mock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build func_test
//go:build func_test

// Package aws contains functionality that wraps the AWS SDK
package aws
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/s3/mock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build func_test
//go:build func_test

package s3

Expand Down
2 changes: 1 addition & 1 deletion internal/aws/s3/s3.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build !func_test
//go:build !func_test

package s3

Expand Down
2 changes: 1 addition & 1 deletion internal/console/console_windows.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

// Package console contains utility functions for working with text consoles
package console
Expand Down
2 changes: 1 addition & 1 deletion test/func_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build func_test
//go:build func_test

package test

Expand Down