1package git23import (4 "os"5 "testing"67 "github.com/stretchr/testify/assert"8)910func TestHook(t *testing.T) {11 path := tempPath()12 h := &Hook{13 name: HookPreReceive,14 path: path,15 isSample: false,16 content: "test content",17 }1819 assert.Equal(t, HookPreReceive, h.Name())20 assert.Equal(t, path, h.Path())21 assert.False(t, h.IsSample())22 assert.Equal(t, "test content", h.Content())23}2425func TestHook_Update(t *testing.T) {26 path := tempPath()27 defer func() {28 _ = os.Remove(path)29 }()3031 h := &Hook{32 name: HookPreReceive,33 path: path,34 isSample: false,35 }36 err := h.Update("test content")37 if err != nil {38 t.Fatal(err)39 }4041 p, err := os.ReadFile(path)42 if err != nil {43 t.Fatal(err)44 }45 assert.Equal(t, "test content", string(p))46}