diff options
| author | 2026-03-25 16:22:03 +0000 | |
|---|---|---|
| committer | 2026-03-25 16:22:03 +0000 | |
| commit | 311edcd50f3a84f4b860bde3cb887451d74eaa11 (patch) | |
| tree | be7aa5e9a51e636358f33b1c90637b5024b70dc3 /network/protocol/sideband64k/encoder_writes_frames_test.go | |
| parent | README: Split off contrib, benchmarks, remove history for now I guess, etc. (diff) | |
| signature | No signature | |
network/protocol: Rename from protocol v0.1.110
Diffstat (limited to 'network/protocol/sideband64k/encoder_writes_frames_test.go')
| -rw-r--r-- | network/protocol/sideband64k/encoder_writes_frames_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/network/protocol/sideband64k/encoder_writes_frames_test.go b/network/protocol/sideband64k/encoder_writes_frames_test.go new file mode 100644 index 00000000..4541bf13 --- /dev/null +++ b/network/protocol/sideband64k/encoder_writes_frames_test.go @@ -0,0 +1,58 @@ +package sideband64k_test + +import ( + "bufio" + "bytes" + "testing" + + "codeberg.org/lindenii/furgit/network/protocol/sideband64k" +) + +func TestEncoderWritesFrames(t *testing.T) { + t.Parallel() + + var b bytes.Buffer + + bw := bufio.NewWriter(&b) + enc := sideband64k.NewEncoder(bw) + + err := enc.WriteData([]byte("hi")) + if err != nil { + t.Fatalf("WriteData: %v", err) + } + + err = enc.WriteProgress([]byte("ok")) + if err != nil { + t.Fatalf("WriteProgress: %v", err) + } + + err = enc.WriteError([]byte("no")) + if err != nil { + t.Fatalf("WriteError: %v", err) + } + + err = enc.WriteFlush() + if err != nil { + t.Fatalf("WriteFlush: %v", err) + } + + err = enc.WriteDelim() + if err != nil { + t.Fatalf("WriteDelim: %v", err) + } + + err = enc.WriteResponseEnd() + if err != nil { + t.Fatalf("WriteResponseEnd: %v", err) + } + + err = enc.FlushIO() + if err != nil { + t.Fatalf("FlushIO: %v", err) + } + + want := "0007\x01hi0007\x02ok0007\x03no000000010002" + if got := b.String(); got != want { + t.Fatalf("got %q, want %q", got, want) + } +} |
