Skip to content

Commit 8da12a4

Browse files
committed
tests: IsReadableText() function
1 parent b6d0d6f commit 8da12a4

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log (go-package-manager)
22

3-
## 0.43.3
3+
## 0.43.4
44

55
- ci: implement first tests
66
- fix: `base64` command and write tests for it

gpm.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ scripts:
3232
prebump: "go build ."
3333
prepublish: "go build ."
3434
test: "go test ./tests/..."
35+
test-cover: "go test -cover"
36+
test-cover-html: "go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out"
3537
test1: "echo test1 runs on default environment"
3638
dev:test1: "echo test1 runs on 'dev' environment"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package utils
2+
3+
import (
4+
"testing"
5+
6+
"github.com/mkloubert/go-package-manager/utils"
7+
)
8+
9+
func TestIsReadableTextFunctionWithTextFile(t *testing.T) {
10+
isText := utils.IsReadableText(test1_txt)
11+
if !isText {
12+
t.Error("should be readable text")
13+
}
14+
}
15+
16+
func TestIsReadableTextFunctionWithImageFile(t *testing.T) {
17+
isText := utils.IsReadableText(test1_jpg)
18+
if isText {
19+
t.Error("should be no readable text")
20+
}
21+
}

tests/utils/resources.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package utils
2+
3+
import _ "embed"
4+
5+
//go:embed test1.txt
6+
var test1_txt []byte
7+
8+
//go:embed test1.jpg
9+
var test1_jpg []byte

tests/utils/test1.jpg

20.7 KB
Loading

tests/utils/test1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae1, aliam Aquitani2, tertiam qui ipsorum lingua Celtae3, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garunna4 flumen, a Belgis Matrona5 et Sequana6 dividit. Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos7 animos pertinent, important, proximique sunt Germanis, qui trans Rhenum8 incolunt, quibuscum continenter bellum gerunt. Qua de causa Helvetii9 quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt. Eorum una pars, quam Gallos obtinere dictum est, initium capit a flumine Rhodano10, continetur Garumna flumine, Oceano, finibus Belgarum, attingit etiam ab Sequanis11 et Helvetiis flumen Rhenum, vergit ad septentriones12. Belgae ab extremis Galliae finibus oriuntur, pertinent ad inferiorem partem fluminis Rheni, spectant in septentrionem et orientem solem. Aquitania a Garunna flumine ad Pyrenaeos13 montes et eam partem Oceani quae est ad Hispaniam14 pertinet; spectat inter occasum solis et septentriones.

0 commit comments

Comments
 (0)