good morning!!!!

Skip to content
Snippets Groups Projects
Commit 0cb8baa8 authored by a's avatar a
Browse files

more tests

parent a6927418
Branches
Tags
No related merge requests found
Pipeline #871 failed
test-libs: test-libs:
stage: test stage: test
image: golang:1.17-alpine3.15 image: golang:1.18-alpine3.15
script: script:
- apk add make - go test ./...
- make test_all
tidy:
go mod tidy
test_all: test_bufpool
test_bufpool:
cd bufpool && go test -bench=.
File moved
package fs_weed_test
import (
"log"
"net/http"
"os"
"testing"
"gfx.cafe/open/goutil/filing/api_weed"
"gfx.cafe/open/goutil/filing/fs_weed"
"gfx.cafe/open/goutil/httpclient"
)
func TestHashUnicode(t *testing.T) {
url := os.Getenv("FILER_ADDR")
user := os.Getenv("FILER_USER")
pass := os.Getenv("FILER_PASS")
client := api_weed.NewClient(httpclient.New(http.DefaultClient).WithGFX(user, pass))
filer := fs_weed.New(url, client)
log.Println(filer.ListFiles())
wow, err := filer.OpenFile("narwhal.png", 0, 0)
if err != nil {
t.Fatalf("failed to open file: %s", err)
}
defer wow.Close()
wow2, err := filer.OpenFile("narwhal2.png", 0, 0)
if err != nil {
t.Fatalf("failed to open file: %s", err)
}
defer wow.Close()
wowhash := wow.Hash()
wow2hash := wow2.Hash()
if wowhash == 0 || wow2hash == 0 {
t.Fatalf("expected hash %d and %d to not be 0", wowhash, wow2hash)
}
if wowhash != wow2hash {
t.Fatalf("expected hash %d to equal %d", wowhash, wow2hash)
}
wowdat, err := wow.Data()
if err != nil {
t.Fatalf("failed to read data for wow")
}
wow2dat, err := wow2.Data()
if err != nil {
t.Fatalf("failed to read data for wow2")
}
if len(wowdat) == 0 || len(wow2dat) == 0 {
t.Fatalf("expected data %s and %s to not be len 0", wowdat, wow2dat)
}
if string(wowdat) != string(wow2dat) {
t.Fatalf("expected data %s to equal %s", wowdat, wow2dat)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment