blob: cd450b6cadf14e56bdbe0b72b4a0df446ed13a20 [file] [edit]
// Copyright 2022 Google LLC
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package common
import (
"flag"
"testing"
"github.com/stretchr/testify/require"
)
func TestFlagSetOpt_UsingFlagSetOptChangesFlagSet_Success(t *testing.T) {
myFlagSet := flag.NewFlagSet("my-flagset-name", flag.ContinueOnError)
err := InitWith("my-app-name", FlagSetOpt(myFlagSet))
// Expected to fail since this will parse the os.Args of this unit test, and
// we haven't specified any flags.
require.Error(t, err)
require.Equal(t, myFlagSet, FlagSet)
require.True(t, FlagSet.Parsed())
}