Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Configuration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Application
Configuration
Commits
10d8b039
Verified
Commit
10d8b039
authored
6 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
chore: add new test for boolValue
parent
b5af8729
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
go.sum
+0
-23
0 additions, 23 deletions
go.sum
issue-17_test.go
+63
-0
63 additions, 0 deletions
issue-17_test.go
value-bool_test.go
+29
-0
29 additions, 0 deletions
value-bool_test.go
with
92 additions
and
23 deletions
go.sum
+
0
−
23
View file @
10d8b039
...
...
@@ -11,10 +11,6 @@ github.com/kinbiko/jsonassert v1.1.1 h1:DB12divY+YB+cVpHULLuKePSi6+ui4M/shHSzJIS
github.com/kinbiko/jsonassert
v1.1.1/go.mod h1:
NO4lzrogohtIdNUNzx8sdzB55M4R4Q1bsrWVdqQ7C+A=
github.com/magiconair/properties
v1.8.7 h1:
IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties
v1.8.7/go.mod h1:
Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/pelletier/go-toml/v2
v2.1.1 h1:
LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2
v2.1.1/go.mod h1:
tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pelletier/go-toml/v2
v2.2.1 h1:
9TA9+T8+8CUCO2+WYnDLCgrYi9+omqKXyjDtosvtEhg=
github.com/pelletier/go-toml/v2
v2.2.1/go.mod h1:
1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pelletier/go-toml/v2
v2.2.3 h1:
YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2
v2.2.3/go.mod h1:
MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pmezard/go-difflib
v1.0.0 h1:
4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
...
...
@@ -22,14 +18,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/r3labs/diff/v3
v3.0.1 h1:
CBKqf3XmNRHXKmdU7mZP1w7TV0pDyVCis1AUHtA4Xtg=
github.com/r3labs/diff/v3
v3.0.1/go.mod h1:
f1S9bourRbiM66NskseyUdo0fTmEE0qKrikYJX63dgo=
github.com/stretchr/objx
v0.1.0/go.mod h1:
HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx
v0.4.0/go.mod h1:
YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx
v0.5.0/go.mod h1:
Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx
v0.5.2/go.mod h1:
FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify
v1.6.1/go.mod h1:
6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify
v1.7.1/go.mod h1:
6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify
v1.8.0/go.mod h1:
yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify
v1.8.4 h1:
CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify
v1.8.4/go.mod h1:
sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify
v1.9.0 h1:
HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify
v1.9.0/go.mod h1:
r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vmihailenco/msgpack/v5
v5.3.5/go.mod h1:
7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
...
...
@@ -43,20 +32,8 @@ gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.9.2 h1:cbrnohA6SyqH6
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder
v0.9.2/go.mod h1:
MqCBFv7DXKoBE2rZDc51LGvl2QI7Kz0D+XkQ0izj+ws=
gitlab.schukai.com/oss/libraries/go/utilities/watch
v0.4.0 h1:
5jwbpUbE721pinIAgzQCfBEnjMjqd/rDQl6gNplpz1M=
gitlab.schukai.com/oss/libraries/go/utilities/watch
v0.4.0/go.mod h1:
1pP8q6sEYUXs8rRSXOBCshjGqg6JtVTx8NPkTBNZHwk=
golang.org/x/exp
v0.0.0-20231214170342-aacd6d4b4611 h1:
qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4=
golang.org/x/exp
v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:
iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/exp
v0.0.0-20240103183307-be819d1f06fc h1:
ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM=
golang.org/x/exp
v0.0.0-20240103183307-be819d1f06fc/go.mod h1:
iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/exp
v0.0.0-20240416160154-fe59bbe5cc7f h1:
99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
golang.org/x/exp
v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:
/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
golang.org/x/exp
v0.0.0-20240909161429-701f63a606c0 h1:
e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
golang.org/x/exp
v0.0.0-20240909161429-701f63a606c0/go.mod h1:
2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
golang.org/x/sys
v0.15.0 h1:
h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys
v0.15.0/go.mod h1:
/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys
v0.16.0 h1:
xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys
v0.16.0/go.mod h1:
/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys
v0.19.0 h1:
q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys
v0.19.0/go.mod h1:
/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys
v0.25.0 h1:
r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys
v0.25.0/go.mod h1:
/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1
v0.0.0-20161208181325-20d25e280405 h1:
yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
...
...
This diff is collapsed.
Click to expand it.
issue-17_test.go
0 → 100644
+
63
−
0
View file @
10d8b039
// Copyright 2022 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package
configuration
import
(
"github.com/stretchr/testify/assert"
"os"
"testing"
)
type
Issue17Struct
struct
{
P1
*
BoolValue
`json:"p1" yaml:"p1"`
P2
*
BoolValue
`json:"p2" yaml:"p2"`
}
func
createIssue17TempFile
(
content
string
)
(
string
,
error
)
{
file
,
err
:=
os
.
CreateTemp
(
""
,
"tempfile"
)
if
err
!=
nil
{
return
""
,
err
}
defer
func
()
{
_
=
file
.
Close
()
}()
_
,
err
=
file
.
WriteString
(
content
)
if
err
!=
nil
{
return
""
,
err
}
return
file
.
Name
(),
nil
}
func
TestIssue17LoadBool
(
t
*
testing
.
T
)
{
c
:=
New
(
Issue17Struct
{})
n
,
err
:=
createIssue17TempFile
(
`
p1: true
p2: off
`
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
c
.
SetMnemonic
(
"my-app"
)
c
.
AddFile
(
n
)
c
.
Import
()
_
=
os
.
Remove
(
n
)
if
c
.
errors
!=
nil
{
t
.
Fatal
(
c
.
errors
)
}
assert
.
Equal
(
t
,
"true"
,
c
.
Config
()
.
P1
.
String
())
assert
.
Equal
(
t
,
true
,
c
.
Config
()
.
P1
.
IsTrue
())
assert
.
Equal
(
t
,
"false"
,
c
.
Config
()
.
P2
.
String
())
assert
.
Equal
(
t
,
false
,
c
.
Config
()
.
P2
.
IsTrue
())
}
This diff is collapsed.
Click to expand it.
value-bool_test.go
+
29
−
0
View file @
10d8b039
...
...
@@ -222,6 +222,35 @@ func TestBoolValueJsonDecode(t *testing.T) {
}
}
func
TestBoolValueYamlDecode2
(
t
*
testing
.
T
)
{
yamlContent
:=
`
value1: true
value2: false
value3: on
value4: 1
`
var
unmarshal
map
[
string
]
BoolValue
data
:=
[]
byte
(
yamlContent
)
err
:=
yaml
.
Unmarshal
(
data
,
&
unmarshal
)
if
err
!=
nil
{
t
.
Errorf
(
"Unmarshaling failed when it should not have: %v"
,
err
)
return
}
if
unmarshal
[
"value1"
]
.
String
()
!=
"true"
{
t
.
Errorf
(
"Unmarshaled value %v does not match original %v"
,
unmarshal
,
"true"
)
}
if
unmarshal
[
"value2"
]
.
String
()
!=
"false"
{
t
.
Errorf
(
"Unmarshaled value %v does not match original %v"
,
unmarshal
,
"false"
)
}
if
unmarshal
[
"value3"
]
.
String
()
!=
"true"
{
t
.
Errorf
(
"Unmarshaled value %v does not match original %v"
,
unmarshal
,
"true"
)
}
if
unmarshal
[
"value4"
]
.
String
()
!=
"true"
{
t
.
Errorf
(
"Unmarshaled value %v does not match original %v"
,
unmarshal
,
"true"
)
}
}
func
TestBoolValueYamlDecode
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment