git.iko.soy/typeable/oauth2-proxy
on master help sign in
Determine line count for yaml load test dynamically

Adding a new option to the yaml alpha config will result in failed tests unless you manually increment the line count. This commit computes this dynamically.

commit733b3fe642c5149b80fb0785240e4ff84ffcb5d2 authorFabian Stelzer <fs@gigacodes.de> dateMon 9 Aug 2021, 14:01 (5 years ago) parent12ab4ef
1 file changed+3−1
main_test.go+3−1
main_test.go+3−1
@@ -2,8 +2,10 @@ package main
22
33import (
44 "errors"
5+ "fmt"
56 "io/ioutil"
67 "os"
8+ "strings"
79 "time"
810
911 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -233,7 +235,7 @@ redirect_url="http://localhost:4180/oauth2/callback"
233235 configContent: testCoreConfig,
234236 alphaConfigContent: testAlphaConfig + ":",
235237 expectedOptions: func() *options.Options { return nil },
236− expectedErr: errors.New("failed to load alpha options: error unmarshalling config: error converting YAML to JSON: yaml: line 50: did not find expected key"),
238+ expectedErr: fmt.Errorf("failed to load alpha options: error unmarshalling config: error converting YAML to JSON: yaml: line %d: did not find expected key", strings.Count(testAlphaConfig, "\n")),
237239 }),
238240 Entry("with alpha configuration and bad core configuration", loadConfigurationTableInput{
239241 configContent: testCoreConfig + "unknown_field=\"something\"",