Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
keystore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
id
keystore
Commits
3a59b1e0
Commit
3a59b1e0
authored
2 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Add a test for deferred configuration deserialization
parent
3e61e87d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/backend_test.go
+37
-0
37 additions, 0 deletions
backend/backend_test.go
with
37 additions
and
0 deletions
backend/backend_test.go
0 → 100644
+
37
−
0
View file @
3a59b1e0
package
backend
import
(
"testing"
"gopkg.in/yaml.v3"
)
var
testYAML
=
`---
type: "test-type"
params:
param1: 42
param2: foo
`
type
testParams
struct
{
Param1
int
`yaml:"param1"`
Param2
string
`yaml:"param2"`
}
func
TestPartialConfigDeserialization
(
t
*
testing
.
T
)
{
var
c
Config
var
p
testParams
if
err
:=
yaml
.
Unmarshal
([]
byte
(
testYAML
),
&
c
);
err
!=
nil
{
t
.
Fatalf
(
"first unmarshal: %v"
,
err
)
}
if
err
:=
c
.
Params
.
Decode
(
&
p
);
err
!=
nil
{
t
.
Fatalf
(
"second unmarshal: %v"
,
err
)
}
if
p
.
Param1
!=
42
{
t
.
Errorf
(
"param1 is %d, expected 42"
,
p
.
Param1
)
}
if
p
.
Param2
!=
"foo"
{
t
.
Errorf
(
"param2 is '%s', expected 'foo'"
,
p
.
Param2
)
}
}
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