Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
gh-aw/pkg/parser/content_extractor_features_test.go at main · github/gh-aw · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
github
gh-aw
Repository navigation
Code
Issues
345
(345)
Pull requests
4
(4)
Only collaborators can create PRs
Discussions
Actions
Projects
Wiki
Security and quality
15
(15)
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
gh-aw
/
pkg
/
parser
/
content_extractor_features_test.go
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
198 lines (173 loc) · 5.92 KB
main
Breadcrumbs
gh-aw
/
pkg
/
parser
/
content_extractor_features_test.go
Copy path
Top
File metadata and controls
Code
Blame
198 lines (173 loc) · 5.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
//go:build !integration
package
parser
import
(
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func
TestExtractFeaturesFromContent_ValidFeatures
(
t
*
testing.
T
) {
content
:=
`---
features:
feature1: true
feature2: false
feature3: "enabled"
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error on valid features"
)
assert
.
NotEmpty
(
t
,
result
,
"Should return non-empty result"
)
assert
.
Contains
(
t
,
result
,
"feature1"
,
"Should contain feature1"
)
assert
.
Contains
(
t
,
result
,
"feature2"
,
"Should contain feature2"
)
assert
.
Contains
(
t
,
result
,
"feature3"
,
"Should contain feature3"
)
}
func
TestExtractFeaturesFromContent_NoFeatures
(
t
*
testing.
T
) {
content
:=
`---
engine: copilot
on: issues
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error when no features"
)
assert
.
Equal
(
t
,
"{}"
,
result
,
"Should return empty object when no features"
)
}
func
TestExtractFeaturesFromContent_EmptyFeatures
(
t
*
testing.
T
) {
content
:=
`---
features: {}
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error on empty features"
)
assert
.
Equal
(
t
,
"{}"
,
result
,
"Should return empty object for empty features"
)
}
func
TestExtractFeaturesFromContent_NoFrontmatter
(
t
*
testing.
T
) {
content
:=
`# Test Workflow
This workflow has no frontmatter.
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error when no frontmatter"
)
assert
.
Equal
(
t
,
"{}"
,
result
,
"Should return empty object when no frontmatter"
)
}
func
TestExtractFeaturesFromContent_ComplexFeatures
(
t
*
testing.
T
) {
content
:=
`---
features:
string-feature: "value"
bool-feature: true
number-feature: 42
nested-feature:
key1: value1
key2: value2
array-feature:
- item1
- item2
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error on complex features"
)
assert
.
NotEmpty
(
t
,
result
,
"Should return non-empty result"
)
assert
.
Contains
(
t
,
result
,
"string-feature"
,
"Should contain string-feature"
)
assert
.
Contains
(
t
,
result
,
"bool-feature"
,
"Should contain bool-feature"
)
assert
.
Contains
(
t
,
result
,
"number-feature"
,
"Should contain number-feature"
)
assert
.
Contains
(
t
,
result
,
"nested-feature"
,
"Should contain nested-feature"
)
assert
.
Contains
(
t
,
result
,
"array-feature"
,
"Should contain array-feature"
)
}
func
TestExtractFeaturesFromContent_MalformedYAML
(
t
*
testing.
T
) {
content
:=
`---
features: [this is not valid yaml
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
// Should return empty object on error, not propagate error
require
.
NoError
(
t
,
err
,
"Should not error on malformed YAML"
)
assert
.
Equal
(
t
,
"{}"
,
result
,
"Should return empty object on malformed YAML"
)
}
func
TestExtractFeaturesFromContent_FeaturesWithSpecialCharacters
(
t
*
testing.
T
) {
content
:=
`---
features:
feature-with-dash: true
feature_with_underscore: false
feature.with.dot: "enabled"
feature:with:colon: 123
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error on features with special characters"
)
assert
.
NotEmpty
(
t
,
result
,
"Should return non-empty result"
)
// The exact keys depend on YAML parsing, but we should get some features
assert
.
NotEqual
(
t
,
"{}"
,
result
,
"Should contain features"
)
}
func
TestExtractFeaturesFromContent_OnlyFeaturesInFrontmatter
(
t
*
testing.
T
) {
content
:=
`---
features:
test-feature: true
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error"
)
assert
.
NotEmpty
(
t
,
result
,
"Should return features"
)
assert
.
Contains
(
t
,
result
,
"test-feature"
,
"Should contain test-feature"
)
}
func
TestExtractFeaturesFromContent_MultipleFrontmatterFields
(
t
*
testing.
T
) {
content
:=
`---
engine: copilot
on: issues
features:
test-feature: true
another-feature: false
permissions:
contents: read
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error"
)
assert
.
NotEmpty
(
t
,
result
,
"Should return features"
)
assert
.
Contains
(
t
,
result
,
"test-feature"
,
"Should contain test-feature"
)
assert
.
Contains
(
t
,
result
,
"another-feature"
,
"Should contain another-feature"
)
// Should NOT contain other frontmatter fields
assert
.
NotContains
(
t
,
result
,
"engine"
,
"Should not contain non-feature fields"
)
assert
.
NotContains
(
t
,
result
,
"permissions"
,
"Should not contain non-feature fields"
)
}
func
TestExtractFeaturesFromContent_BooleanValues
(
t
*
testing.
T
) {
content
:=
`---
features:
enabled-feature: true
disabled-feature: false
yes-feature: yes
no-feature: no
on-feature: on
off-feature: off
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error"
)
assert
.
NotEmpty
(
t
,
result
,
"Should return features"
)
// All these should be parsed as boolean features
assert
.
Contains
(
t
,
result
,
"enabled-feature"
,
"Should contain enabled-feature"
)
assert
.
Contains
(
t
,
result
,
"disabled-feature"
,
"Should contain disabled-feature"
)
}
func
TestExtractFeaturesFromContent_NumericValues
(
t
*
testing.
T
) {
content
:=
`---
features:
int-feature: 42
float-feature: 3.14
negative-feature: -10
zero-feature: 0
---
# Test Workflow
`
result
,
err
:=
extractFrontmatterField
(
content
,
"features"
,
"{}"
)
require
.
NoError
(
t
,
err
,
"Should not error"
)
assert
.
NotEmpty
(
t
,
result
,
"Should return features"
)
assert
.
Contains
(
t
,
result
,
"int-feature"
,
"Should contain int-feature"
)
assert
.
Contains
(
t
,
result
,
"float-feature"
,
"Should contain float-feature"
)
assert
.
Contains
(
t
,
result
,
"negative-feature"
,
"Should contain negative-feature"
)
assert
.
Contains
(
t
,
result
,
"zero-feature"
,
"Should contain zero-feature"
)
}
You can’t perform that action at this time.