-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZEA-4209: Allow setting specific Bun version (#367)
#### Description (required) - **feat(planner/bun): Implement Determine[Bun]Version** - **feat(planner/nodejs): Pick BunVersion** #### Related issues & labels (optional) - Closes #348, Closes ZEA-4209 - Suggested label: enhancement
- Loading branch information
Showing
9 changed files
with
140 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package bun_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/afero" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/zeabur/zbpack/internal/bun" | ||
"github.com/zeabur/zbpack/pkg/plan" | ||
) | ||
|
||
func TestBunVersion(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("unspecified", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
fs := afero.NewMemMapFs() | ||
_ = afero.WriteFile(fs, "package.json", []byte(`{}`), 0o644) | ||
|
||
ctx := bun.CreateBunContext(bun.GetMetaOptions{ | ||
Src: fs, | ||
Config: plan.NewProjectConfigurationFromFs(fs, ""), | ||
}) | ||
|
||
version := bun.DetermineVersion(ctx) | ||
assert.Equal(t, "latest", version) | ||
}) | ||
|
||
t.Run("exact version", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
fs := afero.NewMemMapFs() | ||
_ = afero.WriteFile(fs, "package.json", []byte(`{"engines":{"bun":"1.2.3"}}`), 0o644) | ||
|
||
ctx := bun.CreateBunContext(bun.GetMetaOptions{ | ||
Src: fs, | ||
Config: plan.NewProjectConfigurationFromFs(fs, ""), | ||
}) | ||
|
||
version := bun.DetermineVersion(ctx) | ||
assert.Equal(t, "1.2", version) | ||
}) | ||
|
||
t.Run("range version", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
fs := afero.NewMemMapFs() | ||
_ = afero.WriteFile(fs, "package.json", []byte(`{"engines":{"bun":"^1.2.3"}}`), 0o644) | ||
|
||
ctx := bun.CreateBunContext(bun.GetMetaOptions{ | ||
Src: fs, | ||
Config: plan.NewProjectConfigurationFromFs(fs, ""), | ||
}) | ||
|
||
version := bun.DetermineVersion(ctx) | ||
assert.Equal(t, "1", version) | ||
}) | ||
} |
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