2023-06-21 15:28:15 +03:00
|
|
|
package cli_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-11-20 04:06:36 +03:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2023-06-21 15:28:15 +03:00
|
|
|
"github.com/neilotoole/sq/cli"
|
2024-01-15 04:45:34 +03:00
|
|
|
"github.com/neilotoole/sq/libsq/core/lg/lgt"
|
2023-06-21 15:28:15 +03:00
|
|
|
"github.com/neilotoole/sq/libsq/core/options"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRegisterDefaultOpts(t *testing.T) {
|
|
|
|
reg := &options.Registry{}
|
|
|
|
cli.RegisterDefaultOpts(reg)
|
2024-02-10 03:06:07 +03:00
|
|
|
lgt.New(t).Debug("options.Registry (after)", "reg", reg)
|
2023-06-21 15:28:15 +03:00
|
|
|
|
|
|
|
keys := reg.Keys()
|
2024-02-10 03:06:07 +03:00
|
|
|
require.Len(t, keys, 54)
|
2023-06-21 15:28:15 +03:00
|
|
|
|
|
|
|
for _, opt := range reg.Opts() {
|
|
|
|
opt := opt
|
|
|
|
t.Run(opt.Key(), func(t *testing.T) {
|
|
|
|
require.NotNil(t, opt)
|
|
|
|
require.NotEmpty(t, opt.Key())
|
|
|
|
require.NotNil(t, opt.GetAny(nil))
|
|
|
|
require.NotNil(t, opt.DefaultAny())
|
|
|
|
require.Equal(t, opt.GetAny(nil), opt.DefaultAny())
|
|
|
|
require.NotEmpty(t, opt.Usage())
|
2024-02-10 03:06:07 +03:00
|
|
|
require.NotEmpty(t, opt.Flag().Usage)
|
|
|
|
require.True(t, opt.Flag().Short >= 0)
|
2023-06-21 15:28:15 +03:00
|
|
|
require.Equal(t, opt.Key(), opt.String())
|
|
|
|
require.NotEmpty(t, opt.Help())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|