MCPcopy Index your code
hub / github.com/SignTools/SignTools / TestMain

Function TestMain

main_test.go:50–110  ·  view source on GitHub ↗
(m *testing.M)

Source from the content-addressed store, hash-verified

48var workflowAddress = fmt.Sprintf("http://%s:%d", listenHost, workflowPort)
49
50func TestMain(m *testing.M) {
51 var err error
52 saveDir, err = os.MkdirTemp(".", "data-test")
53 if err != nil {
54 log.Fatal().Err(err).Send()
55 }
56 defer func() {
57 if err := os.RemoveAll(saveDir); err != nil {
58 log.Fatal().Err(err).Send()
59 }
60 }()
61
62 profileDir := filepath.Join(saveDir, "profiles", profileId)
63 if err := os.MkdirAll(profileDir, os.ModePerm); err != nil {
64 log.Fatal().Err(err).Send()
65 }
66 profileCert, err = ioutil.ReadFile("cert-test.p12")
67 if err != nil {
68 log.Fatal().Err(err).Send()
69 }
70 contentMap := map[string][]byte{
71 "cert.p12": profileCert,
72 "cert_pass.txt": []byte(profileCertPass),
73 "name.txt": []byte(profileName),
74 "prov.mobileprovision": []byte(profileProv),
75 }
76 for key, val := range contentMap {
77 if err := ioutil.WriteFile(filepath.Join(profileDir, key), val, os.ModePerm); err != nil {
78 log.Fatal().Err(err).Send()
79 }
80 }
81
82 config.Current = config.Config{
83 Builder: map[string]builders.Builder{
84 "selfhosted": builders.MakeSelfHosted(&builders.SelfHostedData{
85 Enable: true,
86 Url: workflowAddress,
87 Key: workflowKey,
88 }),
89 },
90 File: &config.File{
91 ServerUrl: serveAddress,
92 SaveDir: saveDir,
93 CleanupIntervalMins: 0,
94 },
95 BuilderKey: builderKey,
96 EnvProfile: &config.EnvProfile{},
97 }
98 storage.Load()
99
100 go startWorkflowServer(listenHost, workflowPort)
101 if err := util.WaitForServer(workflowAddress, 5*time.Second); err != nil {
102 log.Fatal().Err(err).Send()
103 }
104
105 go serve(listenHost, servePort)
106 if err := util.WaitForServer(serveAddress, 5*time.Second); err != nil {
107 log.Fatal().Err(err).Send()

Callers

nothing calls this directly

Calls 5

MakeSelfHostedFunction · 0.92
LoadFunction · 0.92
WaitForServerFunction · 0.92
startWorkflowServerFunction · 0.85
serveFunction · 0.85

Tested by

no test coverage detected