updated ui/dist and some lint warnings
This commit is contained in:
@@ -34,11 +34,11 @@ func MoveDirContent(src string, dest string, rootExclude ...string) error {
|
||||
|
||||
moved := map[string]string{}
|
||||
|
||||
tryRollback := func() ([]error) {
|
||||
tryRollback := func() []error {
|
||||
errs := []error{}
|
||||
|
||||
for old, new := range moved {
|
||||
if err := os.Rename(new, old); err != nil{
|
||||
if err := os.Rename(new, old); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ func MoveDirContent(src string, dest string, rootExclude ...string) error {
|
||||
new := filepath.Join(dest, basename)
|
||||
|
||||
if err := os.Rename(old, new); err != nil {
|
||||
if errs := tryRollback(); len(errs) > 0 {
|
||||
if errs := tryRollback(); len(errs) > 0 {
|
||||
// currently just log the rollback errors
|
||||
// in the future we may require go 1.20+ to use errors.Join()
|
||||
log.Println(errs)
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestMoveDirContent(t *testing.T) {
|
||||
|
||||
// missing dest path
|
||||
// ---
|
||||
dir1 := filepath.Join(filepath.Dir(testDir), "a", "b", "c", "d", "_pb_move_dir_content_test_" + security.PseudorandomString(4))
|
||||
dir1 := filepath.Join(filepath.Dir(testDir), "a", "b", "c", "d", "_pb_move_dir_content_test_"+security.PseudorandomString(4))
|
||||
defer os.RemoveAll(dir1)
|
||||
|
||||
if err := osutils.MoveDirContent(testDir, dir1, exclude...); err == nil {
|
||||
@@ -32,14 +32,13 @@ func TestMoveDirContent(t *testing.T) {
|
||||
|
||||
// existing parent dir
|
||||
// ---
|
||||
dir2 := filepath.Join(filepath.Dir(testDir), "_pb_move_dir_content_test_" + security.PseudorandomString(4))
|
||||
dir2 := filepath.Join(filepath.Dir(testDir), "_pb_move_dir_content_test_"+security.PseudorandomString(4))
|
||||
defer os.RemoveAll(dir2)
|
||||
|
||||
if err := osutils.MoveDirContent(testDir, dir2, exclude...); err != nil {
|
||||
t.Fatalf("Expected dir2 to be created, got error: %v", err)
|
||||
}
|
||||
|
||||
|
||||
// find all files
|
||||
files := []string{}
|
||||
filepath.WalkDir(dir2, func(path string, d fs.DirEntry, err error) error {
|
||||
@@ -60,7 +59,7 @@ func TestMoveDirContent(t *testing.T) {
|
||||
filepath.Join(dir2, "test1"),
|
||||
filepath.Join(dir2, "a", "a1"),
|
||||
filepath.Join(dir2, "a", "a2"),
|
||||
};
|
||||
}
|
||||
|
||||
if len(files) != len(expectedFiles) {
|
||||
t.Fatalf("Expected %d files, got %d: \n%v", len(expectedFiles), len(files), files)
|
||||
@@ -91,7 +90,6 @@ func createTestDir(t *testing.T) string {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
f, err := os.OpenFile(filepath.Join(dir, "test1"), os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
|
||||
@@ -73,7 +73,6 @@ func TestBindBody(t *testing.T) {
|
||||
rawBody, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
t.Errorf("[%d] Failed to marshal binded body: %v", i, err)
|
||||
|
||||
}
|
||||
|
||||
if scenario.expectBody != string(rawBody) {
|
||||
|
||||
@@ -150,14 +150,8 @@ func TestSend(t *testing.T) {
|
||||
|
||||
received := []string{}
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case m, ok := <-c.Channel():
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
received = append(received, m.Name)
|
||||
}
|
||||
for m := range c.Channel() {
|
||||
received = append(received, m.Name)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Package template is a thin wrapper arround the standard html/template
|
||||
// Package template is a thin wrapper around the standard html/template
|
||||
// and text/template packages that implements a convenient registry to
|
||||
// load and cache templates on the fly concurrently.
|
||||
//
|
||||
// It was created to assist the JSVM plugin HTML rendering, but could be used in other Go code.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// registry := template.NewRegistry()
|
||||
//
|
||||
// html1, err := registry.LoadFiles(
|
||||
|
||||
Reference in New Issue
Block a user