Go
SQL sorguları
Fonksiyonlar
Dosya işlemleri
API örnekleri
Veri dönüştürme
Sınıflar
Lisans: Belirtilmemis
Go — installer_test.go
Go — SQL sorguları, Fonksiyonlar, Dosya işlemleri. Fonksiyonlar: TestBase64Encode, TestHumanSize, TestInstallerShellTemplate, TestWriteInstaller, extractSection. SQL sorgusu içerir.
Sınırlı Önizleme Politikası: Bu kodun açık kaynak lisansı doğrulanamadığı için telif kuralları gereği yalnızca kısa önizlemesi gösterilmektedir. Tam kod için
orijinal kaynağa gidin ↗.
package main
import (
"bytes"
"encoding/base64"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
)
func TestBase64Encode(t *testing.T) {
tests := []struct {
name string
input []byte
}{
{"empty", nil},
{"short", []byte("hello")},
{"exactly 76 chars decoded", bytes.Repeat([]byte("A"), 57)}, // 57 bytes → 76 base64 chars
{"long binary", bytes.Repeat([]byte{0xff, 0x00, 0xab}, 100)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
encoded := base64Encode(tt.input)
// Every line should be ≤ 76 chars
for i, line := range strings.Split(encoded, "\n") {
if len(line) > 76 {
t.Errorf("line %d has %d chars (max 76): %q", i, len(line), line[:40]+"...")
}
}
// Round-trip: decode must match original
clean := strings.ReplaceAll(encoded, "\n", "")
decoded, err := base64.StdEncoding.DecodeString(clean)
if err != nil {
t.Fatalf("decode error: %v", err)Tespit Edilen SQL Sorguları
with __PAYLOAD_BELOW__ marker
with the payload marker as the last line
with just the package name