MCPcopy Create free account
hub / github.com/cogentcore/core / TestConfigFunc

Function TestConfigFunc

cli/cli_test.go:153–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestConfigFunc(t *testing.T) {
154 cfg := &TestConfig{}
155 os.Args = []string{"myapp", "-no-net-data", "build", "-gpu", "../main", "-Note", "Hello, World", "-v", "-PAT_PARAMS_SPARSENESS=4"}
156 cmd, err := config(DefaultOptions("My App", "My App is an awesome app"), cfg, &Cmd[*TestConfig]{
157 Func: func(tc *TestConfig) error { return nil },
158 Name: "build",
159 Doc: "build builds stuff",
160 })
161 if err != nil {
162 t.Fatal(err)
163 }
164 if cmd != "build" {
165 t.Errorf("expected command to be build but got %q", cmd)
166 }
167 if cfg.NetData || !cfg.GPU || cfg.Note != "Hello, World" || cfg.PatParams.Sparseness != 4 || !reflect.DeepEqual(cfg.StrSlice, []string{"../main"}) {
168 t.Errorf("error setting configuration info (config: %#v)", cfg)
169 }
170 if logx.UserLevel != slog.LevelInfo {
171 t.Errorf("expected logx user level to be info but it is %v", logx.UserLevel)
172 }
173}
174
175func TestDefaults(t *testing.T) {
176 cfg := &TestConfig{}

Callers

nothing calls this directly

Calls 3

configFunction · 0.85
DefaultOptionsFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected