-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_test.go
More file actions
47 lines (38 loc) · 916 Bytes
/
app_test.go
File metadata and controls
47 lines (38 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"context"
"errors"
"testing"
)
func TestApp_InitError(t *testing.T) {
app := &App{}
if app.HasInitError() {
t.Error("Expected no init error for empty app")
}
if app.GetInitError() != "" {
t.Error("Expected empty init error message")
}
app.initError = errors.New("initialization failed")
if !app.HasInitError() {
t.Error("Expected init error returning true")
}
if app.GetInitError() != "initialization failed" {
t.Errorf("Expected 'initialization failed', got '%s'", app.GetInitError())
}
}
func TestApp_GetVersion(t *testing.T) {
app := &App{}
// Just verify it doesn't crash and returns something
ver := app.GetVersion()
if ver == "" {
t.Error("Expected non-empty version")
}
}
func TestApp_StartupContext(t *testing.T) {
app := &App{}
ctx := context.Background()
app.startup(ctx)
if app.ctx != ctx {
t.Error("Context was not saved on startup")
}
}