-
Notifications
You must be signed in to change notification settings - Fork 392
fix: docs/config templates upstream #219
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
SeriousCoding789
wants to merge
5
commits into
tronprotocol:develop
Choose a base branch
from
SeriousCoding789:docs/config-templates-upstream
base: develop
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
5 commits
Select commit
Hold shift + click to select a range
f490f1f
docs(config): stop presenting the mainnet and Nile templates as repo …
Little-Peony 38e87ad
chore(templates): drop the mainnet and Nile symlinks
Little-Peony 6dd0ee1
chore(config): remove the mainnet and Nile mirrors from the repo root
Little-Peony d0d6a27
fix(cli): detect a template dir by any known template
Little-Peony 29a9215
refactor: converge findTemplatesDir onto internal/render + fix stale …
Little-Peony 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
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
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,70 @@ | ||
| package render | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
| ) | ||
|
|
||
| // FindTemplatesDir is the single rule every command resolves the on-disk | ||
| // template override through. It used to be copy-pasted into three cmd | ||
| // packages with three different notions of what a templates dir is; these | ||
| // tests pin the one rule so a future edit can't quietly re-fork it. | ||
| func TestFindTemplatesDir(t *testing.T) { | ||
| // chdir into a scratch dir so a real ./templates in the repo root | ||
| // (the private_net_config.conf symlink) can't leak into these cases. | ||
| chdirTemp := func(t *testing.T) string { | ||
| t.Helper() | ||
| dir := t.TempDir() | ||
| t.Chdir(dir) | ||
| return dir | ||
| } | ||
|
|
||
| t.Run("env var wins outright", func(t *testing.T) { | ||
| chdirTemp(t) | ||
| t.Setenv("TROND_TEMPLATES_DIR", "/somewhere/else") | ||
| if got := FindTemplatesDir(); got != "/somewhere/else" { | ||
| t.Fatalf("got %q, want /somewhere/else", got) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("no templates dir means embedded", func(t *testing.T) { | ||
| chdirTemp(t) | ||
| t.Setenv("TROND_TEMPLATES_DIR", "") | ||
| if got := FindTemplatesDir(); got != "" { | ||
| t.Fatalf("got %q, want empty", got) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("dir without a known template means embedded", func(t *testing.T) { | ||
| dir := chdirTemp(t) | ||
| t.Setenv("TROND_TEMPLATES_DIR", "") | ||
| if err := os.Mkdir(filepath.Join(dir, localTemplatesDir), 0o755); err != nil { | ||
| t.Fatalf("mkdir: %v", err) | ||
| } | ||
| if err := os.WriteFile(filepath.Join(dir, localTemplatesDir, "notes.txt"), []byte("x"), 0o644); err != nil { | ||
| t.Fatalf("write: %v", err) | ||
| } | ||
| if got := FindTemplatesDir(); got != "" { | ||
| t.Fatalf("got %q, want empty", got) | ||
| } | ||
| }) | ||
|
|
||
| // Any single known template is enough: keying off one particular | ||
| // network would ignore a directory that only carries the others. | ||
| for network, file := range NetworkTemplate { | ||
| t.Run("dir carrying only "+network, func(t *testing.T) { | ||
| dir := chdirTemp(t) | ||
| t.Setenv("TROND_TEMPLATES_DIR", "") | ||
| if err := os.Mkdir(filepath.Join(dir, localTemplatesDir), 0o755); err != nil { | ||
| t.Fatalf("mkdir: %v", err) | ||
| } | ||
| if err := os.WriteFile(filepath.Join(dir, localTemplatesDir, file), []byte("x"), 0o644); err != nil { | ||
| t.Fatalf("write: %v", err) | ||
| } | ||
| if got := FindTemplatesDir(); got != localTemplatesDir { | ||
| t.Fatalf("got %q, want %q", got, localTemplatesDir) | ||
| } | ||
| }) | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.