-
Notifications
You must be signed in to change notification settings - Fork 0
fix: phase 1 pre-1.0 API cleanup #1
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
Open
peteraba
wants to merge
3
commits into
main
Choose a base branch
from
chore/phase1-pre1-cleanup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,73 @@ | ||
| package envmagic_test | ||
|
|
||
| import ( | ||
| "errors" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/peteraba/envmagic" | ||
| ) | ||
|
|
||
| func TestOpenWithPath_KeyCreated(t *testing.T) { | ||
| xdg := t.TempDir() | ||
| t.Setenv("XDG_CONFIG_HOME", xdg) | ||
| storePath := filepath.Join(t.TempDir(), ".envmagic") | ||
|
|
||
| c1, err := envmagic.OpenWithPath(storePath) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| _ = c1.Close() | ||
| if !c1.KeyCreated() { | ||
| t.Fatal("first open: want KeyCreated true (new key file)") | ||
| } | ||
|
|
||
| c2, err := envmagic.OpenWithPath(storePath) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| _ = c2.Close() | ||
| if c2.KeyCreated() { | ||
| t.Fatal("second open: want KeyCreated false") | ||
| } | ||
| } | ||
|
|
||
| func TestClient_Get_ErrNotFound(t *testing.T) { | ||
| t.Setenv("XDG_CONFIG_HOME", t.TempDir()) | ||
| storePath := filepath.Join(t.TempDir(), ".envmagic") | ||
|
|
||
| c, err := envmagic.OpenWithPath(storePath) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| t.Cleanup(func() { _ = c.Close() }) | ||
|
|
||
| _, err = c.Get(envmagic.DefaultNamespace, "MISSING_VAR") | ||
| if !errors.Is(err, envmagic.ErrNotFound) { | ||
| t.Fatalf("Get: want ErrNotFound, got %v", err) | ||
| } | ||
| } | ||
|
|
||
| func TestOpen_usesDotEnvmagicInCwd(t *testing.T) { | ||
| dir := t.TempDir() | ||
| t.Setenv("XDG_CONFIG_HOME", t.TempDir()) | ||
| store := filepath.Join(dir, ".envmagic") | ||
|
|
||
| c0, err := envmagic.OpenWithPath(store) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| _ = c0.Close() | ||
|
|
||
| t.Chdir(dir) | ||
|
|
||
| c, err := envmagic.Open() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| t.Cleanup(func() { _ = c.Close() }) | ||
|
|
||
| if _, err := c.Get(envmagic.DefaultNamespace, "ANY"); !errors.Is(err, envmagic.ErrNotFound) { | ||
| t.Fatalf("Open cwd store: Get missing: %v", err) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make tag/make releaseare broken by the switch togit describeThe
versionguard andtagtarget both deriveVERSIONfromVERSION_LD = git describe --tags --always --dirty. This creates a catch-22 for every release:git describereturns something likev0.4.0-3-gabcdef(orv0.4.0-3-gabcdef-dirty). Theversionguard passes ("tag not yet created"), andmake tagthen creates a garbage tagv0.4.0-3-gabcdefinstead of the intendedv0.5.0.git tag v0.5.0first,git describereturnsv0.5.0, but theversionguard immediately fails with "Error: version v0.5.0 already exists", blockingmake tagentirely.The old
const version = "v0.4.0"approach worked because the developer bumped that constant tov0.5.0before runningmake tag, andgit describewas never involved. Withgit describeas the sole version source, there is no clean state wheremake tag/make releasecan produce a correct semver tag. GoReleaser itself is unaffected (it uses{{.Version}}from an existing tag), but the localmake releaseworkflow is currently unusable.