Add file upload functionality to the agent. Implement API endpoint for uploading files, including validation and error handling. Update web interface to support file selection and display upload status. Enhance input handling with configurable key delay for text input.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package install
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"tea.chunkbyte.com/kato/go-worm/lib/config"
|
||||
)
|
||||
|
||||
func TestSamePath(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
a, b string
|
||||
want bool
|
||||
}{
|
||||
{`C:\Apps\localagent.exe`, `c:\apps\localagent.exe`, true},
|
||||
{`C:\Apps\localagent.exe`, `C:\Apps\copy.exe`, false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := samePath(tc.a, tc.b); got != tc.want {
|
||||
t.Fatalf("samePath(%q, %q) = %v, want %v", tc.a, tc.b, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstalledExeName(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
dir, err := config.InstallDir()
|
||||
if err != nil {
|
||||
t.Fatalf("InstallDir: %v", err)
|
||||
}
|
||||
exe, err := config.InstalledExe()
|
||||
if err != nil {
|
||||
t.Fatalf("InstalledExe: %v", err)
|
||||
}
|
||||
if filepath.Base(exe) != config.InstalledExeName {
|
||||
t.Fatalf("InstalledExe base = %q, want %q", filepath.Base(exe), config.InstalledExeName)
|
||||
}
|
||||
if filepath.Dir(exe) != dir {
|
||||
t.Fatalf("InstalledExe dir = %q, want %q", filepath.Dir(exe), dir)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user