-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathcode_intel_upload_flags_test.go
More file actions
47 lines (40 loc) · 1.03 KB
/
code_intel_upload_flags_test.go
File metadata and controls
47 lines (40 loc) · 1.03 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
package main
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"github.com/sourcegraph/scip/bindings/go/scip"
)
var exampleSCIPIndex = scip.Index{
Metadata: &scip.Metadata{
TextDocumentEncoding: scip.TextEncoding_UTF8,
ToolInfo: &scip.ToolInfo{
Name: "hello",
Version: "1.0.0",
},
},
}
func exampleSCIPBytes(t *testing.T) []byte {
bytes, err := proto.Marshal(&exampleSCIPIndex)
if err != nil {
t.Fatal(err)
}
return bytes
}
func createTempSCIPFile(t *testing.T, scipFileName string) string {
t.Helper()
dir := t.TempDir()
require.NotEqual(t, "", scipFileName)
scipFilePath := filepath.Join(dir, scipFileName)
err := os.WriteFile(scipFilePath, exampleSCIPBytes(t), 0755)
require.NoError(t, err)
return scipFilePath
}
func TestInferIndexerNameAndVersion(t *testing.T) {
name, version, err := readIndexerNameAndVersion(createTempSCIPFile(t, "index.scip"))
require.NoError(t, err)
require.Equal(t, "hello", name)
require.Equal(t, "1.0.0", version)
}