Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
8e84027c
Unverified
Commit
8e84027c
authored
Sep 25, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-node: test beta-flag naming consistency
parent
cb122b2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
flags_test.go
op-node/flags/flags_test.go
+22
-0
No files found.
op-node/flags/flags_test.go
View file @
8e84027c
package
flags
package
flags
import
(
import
(
"strings"
"testing"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
)
)
...
@@ -29,3 +31,23 @@ func TestUniqueFlags(t *testing.T) {
...
@@ -29,3 +31,23 @@ func TestUniqueFlags(t *testing.T) {
seenCLI
[
name
]
=
struct
{}{}
seenCLI
[
name
]
=
struct
{}{}
}
}
}
}
// TestBetaFlags test that all flags starting with "beta." have "BETA_" in the env var, and vice versa.
func
TestBetaFlags
(
t
*
testing
.
T
)
{
for
_
,
flag
:=
range
Flags
{
envFlag
,
ok
:=
flag
.
(
interface
{
GetEnvVars
()
[]
string
})
if
!
ok
||
len
(
envFlag
.
GetEnvVars
())
==
0
{
// skip flags without env-var support
continue
}
name
:=
flag
.
Names
()[
0
]
envName
:=
envFlag
.
GetEnvVars
()[
0
]
if
strings
.
HasPrefix
(
name
,
"beta."
)
{
assert
.
Contains
(
t
,
envName
,
"BETA_"
,
"%q flag must contain BETA in env var to match
\"
beta.
\"
flag name"
,
name
)
}
if
strings
.
Contains
(
envName
,
"BETA_"
)
{
assert
.
True
(
t
,
strings
.
HasPrefix
(
name
,
"beta."
),
"%q flag must start with
\"
beta.
\"
in flag name to match
\"
BETA_
\"
env var"
,
name
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment