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.
This commit is contained in:
Fabian Stelzer 2021-08-09 14:01:41 +00:00
parent 12ab4ef529
commit 733b3fe642
No known key found for this signature in database
1 changed files with 3 additions and 1 deletions

View File

@ -2,8 +2,10 @@ package main
import ( import (
"errors" "errors"
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"strings"
"time" "time"
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options" "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@ -233,7 +235,7 @@ redirect_url="http://localhost:4180/oauth2/callback"
configContent: testCoreConfig, configContent: testCoreConfig,
alphaConfigContent: testAlphaConfig + ":", alphaConfigContent: testAlphaConfig + ":",
expectedOptions: func() *options.Options { return nil }, expectedOptions: func() *options.Options { return nil },
expectedErr: errors.New("failed to load alpha options: error unmarshalling config: error converting YAML to JSON: yaml: line 50: did not find expected key"), 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")),
}), }),
Entry("with alpha configuration and bad core configuration", loadConfigurationTableInput{ Entry("with alpha configuration and bad core configuration", loadConfigurationTableInput{
configContent: testCoreConfig + "unknown_field=\"something\"", configContent: testCoreConfig + "unknown_field=\"something\"",