-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathmain_test.go
More file actions
47 lines (41 loc) · 1.14 KB
/
main_test.go
File metadata and controls
47 lines (41 loc) · 1.14 KB
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package main
import (
"errors"
"github.com/microsoft/go-sqlcmd/internal/buffer"
"github.com/microsoft/go-sqlcmd/internal/cmdparser"
"github.com/microsoft/go-sqlcmd/internal/cmdparser/dependency"
"github.com/microsoft/go-sqlcmd/internal/output"
"github.com/microsoft/go-sqlcmd/internal/pal"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestMainStart(t *testing.T) {
os.Args[1] = "--help"
main()
}
func TestInitializeCallback(t *testing.T) {
rootCmd = cmdparser.New[*Root](dependency.Options{})
initializeCallback()
}
func TestDisplayHints(t *testing.T) {
buf := buffer.NewMemoryBuffer()
outputter = output.New(output.Options{StandardWriter: buf})
displayHints([]string{"This is a hint"})
assert.Equal(t, pal.LineBreak()+
"HINT:"+
pal.LineBreak()+
" 1. This is a hint"+pal.LineBreak()+pal.LineBreak(), buf.String())
err := buf.Close()
checkErr(err)
}
func TestCheckErr(t *testing.T) {
rootCmd = cmdparser.New[*Root](dependency.Options{})
rootCmd.loggingLevel = 4
checkErr(nil)
assert.Panics(t, func() {
checkErr(errors.New("test error"))
})
}