Compare commits
2 Commits
67b8540cb1
...
5540e65426
| Author | SHA1 | Date | |
|---|---|---|---|
| 5540e65426 | |||
| 410e0a9318 |
@@ -29,7 +29,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Run Claude Assistant
|
- name: Run Claude Assistant
|
||||||
uses: markwylde/claude-code-gitea-action
|
uses: markwylde/claude-code-gitea-action@1.0.20
|
||||||
with:
|
with:
|
||||||
gitea_token: ${{ secrets.GITEA_TOKEN }} # Use standard workflow token
|
gitea_token: ${{ secrets.GITEA_TOKEN }} # Use standard workflow token
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
|
|||||||
@@ -36,14 +36,10 @@ func (rq *RecordQueue) Push(r Record) {
|
|||||||
rq.l.PushBack(r)
|
rq.l.PushBack(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop removes and returns the first Record of the list as the first return value. If the list is
|
// Pop removes and returns the first Record of the queue in the 1st return value. If the list is
|
||||||
// empty returns falso on the 2nd return value, true otherwise.
|
// empty returns falso on the 2nd return value, true otherwise.
|
||||||
func (rq *RecordQueue) Pop() (Record, bool) {
|
func (rq *RecordQueue) Pop() (Record, bool) {
|
||||||
if rq == nil || rq.l == nil {
|
el := rq.frontElement()
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
el := rq.l.Front()
|
|
||||||
if el == nil {
|
if el == nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
@@ -53,6 +49,25 @@ func (rq *RecordQueue) Pop() (Record, bool) {
|
|||||||
return val.(Record), true
|
return val.(Record), true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Peek returns the front Record of the queue in the 1st return value. If the list is empty returns
|
||||||
|
// falso on the 2nd return value, true otherwise.
|
||||||
|
func (rq *RecordQueue) Peek() (Record, bool) {
|
||||||
|
el := rq.frontElement()
|
||||||
|
if el == nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
return el.Value.(Record), true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rq *RecordQueue) frontElement() *list.Element {
|
||||||
|
if rq == nil || rq.l == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return rq.l.Front()
|
||||||
|
}
|
||||||
|
|
||||||
func (rq *RecordQueue) Len() int {
|
func (rq *RecordQueue) Len() int {
|
||||||
if rq == nil || rq.l == nil {
|
if rq == nil || rq.l == nil {
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ func TestRecordQueue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rq RecordQueue
|
var rq RecordQueue
|
||||||
|
|
||||||
if rq.Len() != 0 {
|
if rq.Len() != 0 {
|
||||||
t.Fatalf("zero value should have zero lenght")
|
t.Fatalf("zero value should have zero lenght")
|
||||||
}
|
}
|
||||||
@@ -23,6 +24,11 @@ func TestRecordQueue(t *testing.T) {
|
|||||||
t.Fatalf("Pop() should return (_,false) on a zero value")
|
t.Fatalf("Pop() should return (_,false) on a zero value")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, ok = rq.Peek()
|
||||||
|
if ok {
|
||||||
|
t.Fatalf("Peek() should return (_,false) on a zero value")
|
||||||
|
}
|
||||||
|
|
||||||
rq.Push(nil)
|
rq.Push(nil)
|
||||||
if rq.Len() != 0 {
|
if rq.Len() != 0 {
|
||||||
t.Fatalf("pushing nil should be a no-op")
|
t.Fatalf("pushing nil should be a no-op")
|
||||||
@@ -38,18 +44,39 @@ func TestRecordQueue(t *testing.T) {
|
|||||||
t.Fatalf("pushing 2nd record should result in lenght of 2")
|
t.Fatalf("pushing 2nd record should result in lenght of 2")
|
||||||
}
|
}
|
||||||
|
|
||||||
rec, ok := rq.Pop()
|
peekRec, ok := rq.Peek()
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("Peek() should return (_,true) when the list is not empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
if peekRec, ok := peekRec.(testRecord); ok {
|
||||||
|
if peekRec.id != 1 {
|
||||||
|
t.Fatalf("Peek() should return the 1st record pushed but returned %d", peekRec.id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
t.Fatalf("Peek() should return the original record type")
|
||||||
|
}
|
||||||
|
|
||||||
|
if rq.Len() != 2 {
|
||||||
|
t.Fatalf("Peek() should not affect the list length")
|
||||||
|
}
|
||||||
|
|
||||||
|
popRec, ok := rq.Pop()
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Pop() should return (_,true) when the list is not empty")
|
t.Fatalf("Pop() should return (_,true) when the list is not empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
if rec, ok := rec.(testRecord); ok {
|
if rec, ok := popRec.(testRecord); ok {
|
||||||
if rec.id != 1 {
|
if rec.id != 1 {
|
||||||
t.Fatalf("Pop() should return the first record pushed but returned %d", rec.id)
|
t.Fatalf("Pop() should return the first record pushed but returned %d", rec.id)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
t.Fatalf("Pop() should return the original record")
|
t.Fatalf("Pop() should return the original record")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rq.Len() != 1 {
|
||||||
|
t.Fatalf("Pop() should remove an element from the list")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRecordQueueNilReceiver(t *testing.T) {
|
func TestRecordQueueNilReceiver(t *testing.T) {
|
||||||
@@ -59,7 +86,12 @@ func TestRecordQueueNilReceiver(t *testing.T) {
|
|||||||
t.Fatalf("nil receiver should have zero lenght")
|
t.Fatalf("nil receiver should have zero lenght")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ok := rq.Pop()
|
_, ok := rq.Peek()
|
||||||
|
if ok {
|
||||||
|
t.Fatalf("Peek() on a nil receiver should return (_,false)")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, ok = rq.Pop()
|
||||||
if ok {
|
if ok {
|
||||||
t.Fatalf("Pop() on a nil receiver should return (_,false)")
|
t.Fatalf("Pop() on a nil receiver should return (_,false)")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user