Move distbuild blocks back to distbuild

This commit is contained in:
Fedor Korotkiy 2023-04-26 15:51:11 +04:00
parent 8e45511bc4
commit e8d1af24b3
8 changed files with 10 additions and 34 deletions

View file

@ -1,3 +0,0 @@
# artifacttest
Этот пакет содержит тесты на [artifact](../distbuild/pkg/artifact).

View file

@ -1,4 +1,4 @@
package artifacttest
package artifact_test
import (
"errors"
@ -32,12 +32,13 @@ func newTestCache(t *testing.T) *testCache {
}
require.NoError(t, err)
return &testCache{Cache: cache, tmpDir: tmpDir}
c := &testCache{Cache: cache, tmpDir: tmpDir}
t.Cleanup(c.cleanup)
return c
}
func TestCache(t *testing.T) {
c := newTestCache(t)
defer c.cleanup()
idA := build.ID{'a'}
@ -73,7 +74,6 @@ func TestCache(t *testing.T) {
func TestAbortWrite(t *testing.T) {
c := newTestCache(t)
defer c.cleanup()
idA := build.ID{'a'}
@ -87,7 +87,6 @@ func TestAbortWrite(t *testing.T) {
func TestArtifactExists(t *testing.T) {
c := newTestCache(t)
defer c.cleanup()
idA := build.ID{'a'}

View file

@ -1,4 +1,4 @@
package artifacttest
package artifact_test
import (
"context"
@ -17,9 +17,7 @@ import (
func TestArtifactTransfer(t *testing.T) {
remoteCache := newTestCache(t)
defer remoteCache.cleanup()
localCache := newTestCache(t)
defer localCache.cleanup()
id := build.ID{0x01}

View file

@ -29,16 +29,12 @@ func newEnv(t *testing.T) *env {
mux := http.NewServeMux()
cache := newCache(t)
defer func() {
if cache != nil {
cache.cleanup()
}
}()
handler := filecache.NewHandler(l, cache.Cache)
handler.Register(mux)
server := httptest.NewServer(mux)
t.Cleanup(server.Close)
client := filecache.NewClient(l, server.URL)
@ -48,19 +44,11 @@ func newEnv(t *testing.T) *env {
client: client,
}
cache = nil
return env
}
func (e *env) stop() {
e.server.Close()
e.cache.cleanup()
}
func TestFileUpload(t *testing.T) {
env := newEnv(t)
defer env.stop()
content := bytes.Repeat([]byte("foobar"), 1024*1024)
tmpFilePath := filepath.Join(env.cache.tmpDir, "foo.txt")
@ -115,10 +103,8 @@ func TestFileUpload(t *testing.T) {
func TestFileDownload(t *testing.T) {
env := newEnv(t)
defer env.stop()
localCache := newCache(t)
defer localCache.cleanup()
id := build.ID{0x01}

View file

@ -24,7 +24,9 @@ func newCache(t *testing.T) *testCache {
c, err := filecache.New(tmpDir)
require.NoError(t, err)
return &testCache{Cache: c, tmpDir: tmpDir}
cc := &testCache{Cache: c, tmpDir: tmpDir}
t.Cleanup(cc.cleanup)
return cc
}
func (c *testCache) cleanup() {

View file

@ -1,4 +1,4 @@
package tarstreamtest
package tarstream_test
import (
"bytes"

View file

@ -1,3 +0,0 @@
# filecachetest
Этот пакет содержит тесты на [filecache](../distbuild/pkg/filecache).

View file

@ -1,3 +0,0 @@
# tarstreamtest
Этот пакет содержит тесты на [tarstream](../distbuild/pkg/tarstream).