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
feat: support env tag in config #2577
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2f2d220
feat: support env tag in config
kevwan 77f08d1
chore: add more tests
kevwan 5869aff
chore: add more tests, add stringx.Join
kevwan b325fde
fix: test fail
kevwan 7d9bd23
chore: remove print code
kevwan d1627ed
chore: rename variable
kevwan bf552b3
Merge branch 'master' into feat/conf-env
kevwan File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,131 @@ | ||
package lang | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRepr(t *testing.T) { | ||
var ( | ||
f32 float32 = 1.1 | ||
f64 = 2.2 | ||
i8 int8 = 1 | ||
i16 int16 = 2 | ||
i32 int32 = 3 | ||
i64 int64 = 4 | ||
u8 uint8 = 5 | ||
u16 uint16 = 6 | ||
u32 uint32 = 7 | ||
u64 uint64 = 8 | ||
) | ||
tests := []struct { | ||
v interface{} | ||
expect string | ||
}{ | ||
{ | ||
nil, | ||
"", | ||
}, | ||
{ | ||
mockStringable{}, | ||
"mocked", | ||
}, | ||
{ | ||
new(mockStringable), | ||
"mocked", | ||
}, | ||
{ | ||
newMockPtr(), | ||
"mockptr", | ||
}, | ||
{ | ||
&mockOpacity{ | ||
val: 1, | ||
}, | ||
"{1}", | ||
}, | ||
{ | ||
true, | ||
"true", | ||
}, | ||
{ | ||
false, | ||
"false", | ||
}, | ||
{ | ||
f32, | ||
"1.1", | ||
}, | ||
{ | ||
f64, | ||
"2.2", | ||
}, | ||
{ | ||
i8, | ||
"1", | ||
}, | ||
{ | ||
i16, | ||
"2", | ||
}, | ||
{ | ||
i32, | ||
"3", | ||
}, | ||
{ | ||
i64, | ||
"4", | ||
}, | ||
{ | ||
u8, | ||
"5", | ||
}, | ||
{ | ||
u16, | ||
"6", | ||
}, | ||
{ | ||
u32, | ||
"7", | ||
}, | ||
{ | ||
u64, | ||
"8", | ||
}, | ||
{ | ||
[]byte(`abcd`), | ||
"abcd", | ||
}, | ||
{ | ||
mockOpacity{val: 1}, | ||
"{1}", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.expect, func(t *testing.T) { | ||
assert.Equal(t, test.expect, Repr(test.v)) | ||
}) | ||
} | ||
} | ||
|
||
type mockStringable struct{} | ||
|
||
func (m mockStringable) String() string { | ||
return "mocked" | ||
} | ||
|
||
type mockPtr struct{} | ||
|
||
func newMockPtr() *mockPtr { | ||
return new(mockPtr) | ||
} | ||
|
||
func (m *mockPtr) String() string { | ||
return "mockptr" | ||
} | ||
|
||
type mockOpacity struct { | ||
val int | ||
} |
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.
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.
Does the boolean type should be supported for env?