-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from spatocode/more-runtime-support
Support more runtime auto build
- Loading branch information
Showing
20 changed files
with
675 additions
and
202 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
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
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,79 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewGolangRuntime(t *testing.T) { | ||
assert := assert.New(t) | ||
fakeOutput = "go version go1.21.0 linux/amd64" | ||
r := NewGoRuntime(fakeCommandExecutor{}) | ||
g := r.(*Go) | ||
assert.Equal(RuntimeGo, g.Name) | ||
assert.Equal("1.21.0", g.Version) | ||
} | ||
|
||
func TestNewGolangRuntimeDefaultVersion(t *testing.T) { | ||
assert := assert.New(t) | ||
fakeOutput = "" | ||
r := NewGoRuntime(fakeCommandExecutor{}) | ||
g := r.(*Go) | ||
assert.Equal(RuntimeGo, g.Name) | ||
assert.Equal(DefaultGoVersion, g.Version) | ||
} | ||
|
||
func TestGoGetVersion(t *testing.T) { | ||
assert := assert.New(t) | ||
fakeOutput = "go version go1.21.0 linux/amd64" | ||
r := NewGoRuntime(fakeCommandExecutor{}) | ||
g := r.(*Go) | ||
v, err := g.getVersion() | ||
assert.Nil(err) | ||
assert.Equal(RuntimeGo, g.Name) | ||
assert.Equal("1.21.0", v) | ||
} | ||
|
||
func TestGoGetVersionError(t *testing.T) { | ||
assert := assert.New(t) | ||
fakeOutput = "" | ||
r := NewGoRuntime(fakeCommandExecutor{}) | ||
g := r.(*Go) | ||
v, err := g.getVersion() | ||
assert.NotNil(err) | ||
assert.Equal(RuntimeGo, g.Name) | ||
assert.Equal("", v) | ||
} | ||
|
||
func TestGoLambdaRuntime(t *testing.T) { | ||
assert := assert.New(t) | ||
fakeOutput = "go version go1.21.0 linux/amd64" | ||
r := NewGoRuntime(fakeCommandExecutor{}) | ||
g := r.(*Go) | ||
v, err := g.lambdaRuntime() | ||
assert.Nil(err) | ||
assert.Equal("go1.x", v) | ||
} | ||
|
||
func TestGoBuild(t *testing.T) { | ||
assert := assert.New(t) | ||
fakeOutput = "go version go1.21.0 linux/amd64" | ||
r := NewGoRuntime(fakeCommandExecutor{}) | ||
cfg := &Config{Name: "test", Stage: "env"} | ||
p, f, err := r.Build(cfg) | ||
assert.Nil(err) | ||
assert.Equal("main", p) | ||
assert.Equal("main", f) | ||
} | ||
|
||
func TestGoBuildError(t *testing.T) { | ||
assert := assert.New(t) | ||
fakeOutput = "" | ||
r := NewGoRuntime(fakeCommandExecutor{}) | ||
cfg := &Config{Name: "test", Stage: "env"} | ||
p, f, err := r.Build(cfg) | ||
assert.NotNil(err) | ||
assert.Equal("", p) | ||
assert.Equal("", f) | ||
} |
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,19 @@ | ||
package handlers | ||
|
||
const ( | ||
AwsLambdaHandlerStaticPage = ` | ||
const fs = require('fs'); | ||
const html = fs.readFileSync('index.html', { encoding:'utf8' }); | ||
exports.handler = async (event) => { | ||
const response = { | ||
statusCode: 200, | ||
headers: { | ||
'Content-Type': 'text/html', | ||
}, | ||
body: html, | ||
}; | ||
return response; | ||
}; | ||
` | ||
) |
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.