mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-24 15:55:03 +01:00
fix: explode yaml anchors (#126)
* do not require code changes at several places
This commit is contained in:
35
pkg/model/anchors_test.go
Normal file
35
pkg/model/anchors_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestVerifyCycleIsInvalid(t *testing.T) {
|
||||
var node yaml.Node
|
||||
err := yaml.Unmarshal([]byte(`
|
||||
a: &a
|
||||
ref: *b
|
||||
|
||||
b: &b
|
||||
ref: *a
|
||||
`), &node)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestVerifyNilAliasError(t *testing.T) {
|
||||
var node yaml.Node
|
||||
err := yaml.Unmarshal([]byte(`
|
||||
test:
|
||||
- a
|
||||
- b
|
||||
- c`), &node)
|
||||
*node.Content[0].Content[1].Content[1] = yaml.Node{
|
||||
Kind: yaml.AliasNode,
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
err = resolveAliases(&node)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
Reference in New Issue
Block a user