forked from drone-plugins/drone-github-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin_test.go
31 lines (25 loc) · 953 Bytes
/
plugin_test.go
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
package main // Needs to be same package to be able to access the private func "readStringOrFile"
import (
"testing"
)
func TestReadStringOrFileSelf(t *testing.T) {
contents, err := readStringOrFile("./plugin_test.go")
if err != nil {
t.Error(err)
return
}
if len(contents) == 0 {
t.Errorf("Expected this file to have length > 0, was %d", len(contents))
}
}
func TestReadStringOrFileLongString(t *testing.T) {
s := "if the string is extremely long it will still try to ask the OS to read this as a file which in some cases will not be allowed because of the length of the file name however the plugin might try this anyways but most file systems only allow a maximum of 255 chars for a file name but up to 4096 for a full path thats a lot of characters"
contents, err := readStringOrFile(s)
if err != nil {
t.Error(err)
return
}
if contents != s {
t.Error("Expected readStringOrFile to return input for a long string")
}
}