-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82fbdfa
commit 573c219
Showing
18 changed files
with
685 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package golang | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/klothoplatform/klotho/pkg/core" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_GetArguements(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
source string | ||
want []Argument | ||
wantFound bool | ||
}{ | ||
{ | ||
name: "finds next function Name and args", | ||
source: ` | ||
x = s.my_func("val") | ||
y = s.other_func("something_else) | ||
`, | ||
want: []Argument{ | ||
{Content: `"val"`, Type: "interpreted_string_literal"}, | ||
}, | ||
wantFound: true, | ||
}, | ||
{ | ||
name: "args not required", | ||
source: `v, err := s.someFunc()`, | ||
wantFound: false, | ||
}, | ||
{ | ||
name: "a call containing other function calls as args", | ||
source: `v, err := runtimevar.OpenVariable(context.TODO(), fmt.Sprintf("file://%s?decoder=string", path))`, | ||
want: []Argument{ | ||
{Content: "context.TODO()", Type: "call_expression"}, | ||
{Content: `fmt.Sprintf("file://%s?decoder=string", path)`, Type: "call_expression"}, | ||
}, | ||
wantFound: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
f, err := core.NewSourceFile("", strings.NewReader(tt.source), Language) | ||
if !assert.NoError(err) { | ||
return | ||
} | ||
args, found := getArguements(f.Tree().RootNode()) | ||
|
||
assert.ElementsMatch(tt.want, args) | ||
assert.Equal(tt.wantFound, found) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
FROM public.ecr.aws/lambda/provided:al2 | ||
|
||
WORKDIR ${LAMBDA_TASK_ROOT} | ||
FROM golang:1.20 as builder | ||
|
||
RUN yum install -y golang | ||
RUN go env -w GOPROXY=https://proxy.golang.org,direct | ||
WORKDIR /usr/src/app | ||
ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0 | ||
COPY go.mod ./ | ||
RUN go mod tidy && go mod download && go mod verify | ||
|
||
COPY . . | ||
RUN env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 | ||
RUN go mod tidy | ||
RUN go build -o=/main | ||
RUN go build -o /usr/local/bin/app | ||
|
||
ENTRYPOINT ["/main"] | ||
FROM public.ecr.aws/lambda/provided:al2 | ||
COPY --from=builder /usr/local/bin/app main | ||
ENTRYPOINT ["/main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.