Skip to content

Commit 67f4f49

Browse files
committed
update npm debug tests
1 parent 25e2056 commit 67f4f49

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ require (
3030
github.com/prometheus/client_model v0.6.1
3131
github.com/spf13/cobra v1.9.1
3232
github.com/spf13/pflag v1.0.6
33-
github.com/spf13/viper v1.20.0
33+
github.com/spf13/viper v1.20.1
3434
github.com/stretchr/testify v1.10.0
3535
go.uber.org/zap v1.27.0
3636
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
3737
golang.org/x/sync v0.12.0
3838
golang.org/x/sys v0.31.0
3939
google.golang.org/grpc v1.71.0
40-
google.golang.org/protobuf v1.36.5
40+
google.golang.org/protobuf v1.36.6
4141
k8s.io/api v0.26.10
4242
k8s.io/apiextensions-apiserver v0.26.1
4343
k8s.io/apimachinery v0.26.10
@@ -55,7 +55,7 @@ require (
5555
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
5656
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
5757
github.com/klauspost/compress v1.17.11 // indirect
58-
github.com/sagikazarmark/locafero v0.8.0 // indirect
58+
github.com/sagikazarmark/locafero v0.9.0 // indirect
5959
github.com/sourcegraph/conc v0.3.0 // indirect
6060
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
6161
)

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99
657657
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
658658
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
659659
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
660-
github.com/sagikazarmark/locafero v0.8.0 h1:mXaMVw7IqxNBxfv3LdWt9MDmcWDQ1fagDH918lOdVaQ=
661-
github.com/sagikazarmark/locafero v0.8.0/go.mod h1:UBUyz37V+EdMS3hDF3QWIiVr/2dPrx49OMO0Bn0hJqk=
660+
github.com/sagikazarmark/locafero v0.9.0 h1:GbgQGNtTrEmddYDSAH9QLRyfAHY12md+8YFTqyMTC9k=
661+
github.com/sagikazarmark/locafero v0.9.0/go.mod h1:UBUyz37V+EdMS3hDF3QWIiVr/2dPrx49OMO0Bn0hJqk=
662662
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
663663
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
664664
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
@@ -699,8 +699,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
699699
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
700700
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
701701
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
702-
github.com/spf13/viper v1.20.0 h1:zrxIyR3RQIOsarIrgL8+sAvALXul9jeEPa06Y0Ph6vY=
703-
github.com/spf13/viper v1.20.0/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
702+
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
703+
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
704704
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
705705
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
706706
github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -1133,8 +1133,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
11331133
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
11341134
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
11351135
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1136-
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
1137-
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
1136+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
1137+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
11381138
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
11391139
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
11401140
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

npm/cmd/debug_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package main
33
import (
44
"bytes"
55
"io"
6+
"os"
7+
"path/filepath"
68
"testing"
79

810
dataplane "github.com/Azure/azure-container-networking/npm/pkg/dataplane/debug"
@@ -37,8 +39,28 @@ type testCases struct {
3739
}
3840

3941
func testCommand(t *testing.T, tests []*testCases) {
42+
// Create a temporary config file
43+
configContent := `{
44+
"ResyncPeriodInMinutes": 15,
45+
"ListeningPort": 10091,
46+
"ListeningAddress": "0.0.0.0",
47+
"Toggles": {
48+
"EnablePrometheusMetrics": true,
49+
"EnablePprof": true,
50+
"EnableHTTPDebugAPI": true,
51+
"EnableV2NPM": true,
52+
"PlaceAzureChainFirst": true
53+
}
54+
}`
55+
tmpDir := t.TempDir()
56+
configPath := filepath.Join(tmpDir, "azure-npm.json")
57+
err := os.WriteFile(configPath, []byte(configContent), 0o600)
58+
require.NoError(t, err)
59+
// Set the environment variable to point to our temp config
60+
oldNPMConfig := os.Getenv("NPM_CONFIG")
61+
os.Setenv("NPM_CONFIG", configPath)
62+
defer os.Setenv("NPM_CONFIG", oldNPMConfig)
4063
for _, tt := range tests {
41-
tt := tt
4264
t.Run(tt.name, func(t *testing.T) {
4365
rootCMD := NewRootCmd()
4466
b := bytes.NewBufferString("")

0 commit comments

Comments
 (0)