pico
created pr with
47.1
added 47.2
1: 0306c3f < -: ------- chore: rsync test
2: 971b354 ! 1: 745b513 chore: add `rsync --delete` test
added 47.3
1: 745b513 ! 1: 76a6734 chore: add `rsync --delete` test
added 47.4
1: 76a6734 ! 1: 57bb60c chore: add `rsync --delete` test
added 47.5
1: 57bb60c = 1: 57bb60c chore: add `rsync --delete` test
-: ------- > 2: 5c8d929 chore: test is failing on `--delete`
changed status to
accepted
cmds
checkout latest patchset:
ssh pr.pico.sh print 47 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 47.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 47set PR to open (enables RSS notifications):
ssh pr.pico.sh pr open 47set PR to draft (stops RSS notifications):
ssh pr.pico.sh pr draft 47
Patchset
47.1
chore: rsync test
Eric Bower
2025-02-17T15:36:03ZSemantic diff summary
3 added,
0 modified,
0 signature changed,
1 removed
across 1 analyzed file
+51
-1
pgs/ssh_test.go
#
| ... | ... | @@ -57,6 +57,52 @@ func TestSshServer(t *testing.T) { | |
| 57 | 57 | done <- nil | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | + | func TestSshServerRsync(t *testing.T) { | |
| 61 | + | logger := slog.Default() | |
| 62 | + | dbpool := pgsdb.NewDBMemory(logger) | |
| 63 | + | // setup test data | |
| 64 | + | dbpool.SetupTestData() | |
| 65 | + | st, err := storage.NewStorageMemory(map[string]map[string]string{}) | |
| 66 | + | if err != nil { | |
| 67 | + | panic(err) | |
| 68 | + | } | |
| 69 | + | cfg := NewPgsConfig(logger, dbpool, st) | |
| 70 | + | done := make(chan error) | |
| 71 | + | go StartSshServer(cfg, done) | |
| 72 | + | // Hack to wait for startup | |
| 73 | + | time.Sleep(time.Millisecond * 100) | |
| 74 | + | ||
| 75 | + | user := GenerateUser() | |
| 76 | + | // add user's pubkey to the default test account | |
| 77 | + | dbpool.Pubkeys = append(dbpool.Pubkeys, &db.PublicKey{ | |
| 78 | + | ID: "nice-pubkey", | |
| 79 | + | UserID: dbpool.Users[0].ID, | |
| 80 | + | Key: utils.KeyForKeyText(user.signer.PublicKey()), | |
| 81 | + | }) | |
| 82 | + | ||
| 83 | + | /* client, err := user.NewClient() | |
| 84 | + | if err != nil { | |
| 85 | + | t.Error(err) | |
| 86 | + | return | |
| 87 | + | } | |
| 88 | + | defer client.Close() | |
| 89 | + | ||
| 90 | + | _, err = WriteFilesWithRsync(cfg, client, []string{"index.html", "about.html", "favicon.png", "profile.jpg"}) | |
| 91 | + | if err != nil { | |
| 92 | + | t.Error(err) | |
| 93 | + | return | |
| 94 | + | } | |
| 95 | + | ||
| 96 | + | // test `--delete` functionality | |
| 97 | + | _, err = WriteFilesWithRsync(cfg, client, []string{"index.html", "profile.jpg"}) | |
| 98 | + | if err != nil { | |
| 99 | + | t.Error(err) | |
| 100 | + | return | |
| 101 | + | } */ | |
| 102 | + | ||
| 103 | + | done <- nil | |
| 104 | + | } | |
| 105 | + | ||
| 60 | 106 | type UserSSH struct { | |
| 61 | 107 | username string | |
| 62 | 108 | signer ssh.Signer |
| ... | ... | @@ -157,6 +203,10 @@ func GenerateUser() UserSSH { | |
| 157 | 203 | } | |
| 158 | 204 | } | |
| 159 | 205 | ||
| 206 | + | func WriteFilesWithRsync(cfg *PgsConfig, conn *ssh.Client, files []string) (*os.FileInfo, error) { | |
| 207 | + | return nil, nil | |
| 208 | + | } | |
| 209 | + | ||
| 160 | 210 | func WriteFileWithSftp(cfg *PgsConfig, conn *ssh.Client) (*os.FileInfo, error) { | |
| 161 | 211 | // open an SFTP session over an existing ssh connection. | |
| 162 | 212 | client, err := sftp.NewClient(conn) |