MCPcopy Index your code
hub / github.com/devspace-sh/devspace / TestHookWithoutExecution

Function TestHookWithoutExecution

pkg/devspace/hook/hook_test.go:18–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestHookWithoutExecution(t *testing.T) {
19 // Execute 0 hooks
20 // conf := config.NewConfig(nil, &latest.Config{}, nil, nil, constants.DefaultConfigPath)
21 conf := config.NewConfig(map[string]interface{}{},
22 map[string]interface{}{},
23 latest.NewRaw(),
24 localcache.New(constants.DefaultCacheFolder),
25 &remotecache.RemoteCache{},
26 map[string]interface{}{},
27 constants.DefaultConfigPath)
28 err := ExecuteHooks(devspacecontext.NewContext(context.Background(), nil, log.Discard).WithConfig(conf), nil)
29 if err != nil {
30 t.Fatalf("Failed to execute 0 hooks with error: %v", err)
31 }
32
33 conf = config.NewConfig(map[string]interface{}{},
34 map[string]interface{}{},
35 &latest.Config{
36 Hooks: []*latest.HookConfig{{}},
37 },
38 localcache.New(constants.DefaultCacheFolder),
39 &remotecache.RemoteCache{},
40 map[string]interface{}{},
41 constants.DefaultConfigPath)
42 err = ExecuteHooks(devspacecontext.NewContext(context.Background(), nil, log.Discard).WithConfig(conf), nil)
43 if err != nil {
44 t.Fatalf("Failed to execute 1 hook without when with error: %v", err)
45 }
46
47 conf = config.NewConfig(map[string]interface{}{},
48 map[string]interface{}{},
49 &latest.Config{
50 Hooks: []*latest.HookConfig{{
51 Events: []string{"before:deploy"},
52 }},
53 },
54 localcache.New(constants.DefaultCacheFolder),
55 &remotecache.RemoteCache{},
56 map[string]interface{}{},
57 constants.DefaultConfigPath)
58
59 err = ExecuteHooks(devspacecontext.NewContext(context.Background(), nil, log.Discard).WithConfig(conf), nil)
60 if err != nil {
61 t.Fatalf("Failed to execute 1 hook without When.Before and When.After with error: %v", err)
62 }
63}
64
65func TestHookWithExecution(t *testing.T) {
66 conf := config.NewConfig(map[string]interface{}{},

Callers

nothing calls this directly

Calls 6

NewConfigFunction · 0.92
NewRawFunction · 0.92
NewFunction · 0.92
ExecuteHooksFunction · 0.85
WithConfigMethod · 0.65
FatalfMethod · 0.45

Tested by

no test coverage detected