feat: add FTP and SFTP upload support
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package domain
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDefaultAppConfigIncludesFTPDefaults(t *testing.T) {
|
||||
cfg := DefaultAppConfig()
|
||||
if cfg.FTP.Protocol != FTPProtocolFTP {
|
||||
t.Fatalf("expected default FTP protocol, got %q", cfg.FTP.Protocol)
|
||||
}
|
||||
if cfg.FTP.Port != 21 {
|
||||
t.Fatalf("expected default FTP port 21, got %d", cfg.FTP.Port)
|
||||
}
|
||||
if cfg.FTP.PathPrefix != "snapgo/" {
|
||||
t.Fatalf("expected default path prefix, got %q", cfg.FTP.PathPrefix)
|
||||
}
|
||||
if cfg.FTP.ConnectTimeoutSecs != 10 {
|
||||
t.Fatalf("expected 10 second timeout, got %d", cfg.FTP.ConnectTimeoutSecs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeUsesSFTPDefaultPort(t *testing.T) {
|
||||
cfg := AppConfig{
|
||||
FTP: FTPConfig{
|
||||
Protocol: FTPProtocolSFTP,
|
||||
},
|
||||
}
|
||||
cfg.Normalize()
|
||||
if cfg.FTP.Port != 22 {
|
||||
t.Fatalf("expected SFTP port 22, got %d", cfg.FTP.Port)
|
||||
}
|
||||
if cfg.FTP.AuthMethod != SSHAuthPassword {
|
||||
t.Fatalf("expected password auth default, got %q", cfg.FTP.AuthMethod)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsFTPConfiguredRequiresProtocolHostAndUser(t *testing.T) {
|
||||
cfg := DefaultAppConfig()
|
||||
if cfg.IsFTPConfigured() {
|
||||
t.Fatal("empty FTP destination should not be configured")
|
||||
}
|
||||
cfg.FTP.Host = "files.example.com"
|
||||
cfg.FTP.User = "snapgo"
|
||||
if !cfg.IsFTPConfigured() {
|
||||
t.Fatal("host and user should be enough for a normalized FTP config")
|
||||
}
|
||||
cfg.FTP.Protocol = "invalid"
|
||||
if cfg.IsFTPConfigured() {
|
||||
t.Fatal("invalid protocol should not be configured")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user