Skip to content

Commit a844e10

Browse files
committed
Forgot to uncomment tests
1 parent 5559394 commit a844e10

File tree

1 file changed

+133
-133
lines changed

1 file changed

+133
-133
lines changed

dsc/tests/dsc_mcp.tests.ps1

Lines changed: 133 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -62,153 +62,153 @@ Describe 'Tests for MCP server' {
6262
Send-McpRequest -request $notifyInitialized -notify
6363
}
6464

65-
# It 'Tools/List works' {
66-
# $mcpRequest = @{
67-
# jsonrpc = "2.0"
68-
# id = 2
69-
# method = "tools/list"
70-
# params = @{}
71-
# }
65+
It 'Tools/List works' {
66+
$mcpRequest = @{
67+
jsonrpc = "2.0"
68+
id = 2
69+
method = "tools/list"
70+
params = @{}
71+
}
7272

73-
# $tools = @{
74-
# 'list_dsc_functions' = $false
75-
# 'list_dsc_resources' = $false
76-
# 'show_dsc_resource' = $false
77-
# }
73+
$tools = @{
74+
'list_dsc_functions' = $false
75+
'list_dsc_resources' = $false
76+
'show_dsc_resource' = $false
77+
}
7878

79-
# $response = Send-McpRequest -request $mcpRequest
80-
# $response.id | Should -Be 2
81-
# $response.result.tools.Count | Should -Be $tools.Count
82-
# foreach ($tool in $response.result.tools) {
83-
# $tools.ContainsKey($tool.name) | Should -Be $true
84-
# $tools[$tool.name] = $true
85-
# $tool.description | Should -Not -BeNullOrEmpty
86-
# }
87-
# foreach ($tool in $tools.GetEnumerator()) {
88-
# $tool.Value | Should -Be $true -Because "Tool '$($tool.Key)' was not found in the list of tools"
89-
# }
90-
# }
79+
$response = Send-McpRequest -request $mcpRequest
80+
$response.id | Should -Be 2
81+
$response.result.tools.Count | Should -Be $tools.Count
82+
foreach ($tool in $response.result.tools) {
83+
$tools.ContainsKey($tool.name) | Should -Be $true
84+
$tools[$tool.name] = $true
85+
$tool.description | Should -Not -BeNullOrEmpty
86+
}
87+
foreach ($tool in $tools.GetEnumerator()) {
88+
$tool.Value | Should -Be $true -Because "Tool '$($tool.Key)' was not found in the list of tools"
89+
}
90+
}
9191

92-
# It 'Calling list_dsc_resources works' {
93-
# $mcpRequest = @{
94-
# jsonrpc = "2.0"
95-
# id = 3
96-
# method = "tools/call"
97-
# params = @{
98-
# name = "list_dsc_resources"
99-
# arguments = @{}
100-
# }
101-
# }
92+
It 'Calling list_dsc_resources works' {
93+
$mcpRequest = @{
94+
jsonrpc = "2.0"
95+
id = 3
96+
method = "tools/call"
97+
params = @{
98+
name = "list_dsc_resources"
99+
arguments = @{}
100+
}
101+
}
102102

103-
# $response = Send-McpRequest -request $mcpRequest
104-
# $response.id | Should -BeGreaterOrEqual 3
105-
# $resources = dsc resource list | ConvertFrom-Json -Depth 20 | Select-Object type, kind, description -Unique
106-
# $response.result.structuredContent.resources.Count | Should -Be $resources.Count
107-
# for ($i = 0; $i -lt $resources.Count; $i++) {
108-
# ($response.result.structuredContent.resources[$i].psobject.properties | Measure-Object).Count | Should -BeGreaterOrEqual 3
109-
# $response.result.structuredContent.resources[$i].type | Should -BeExactly $resources[$i].type -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
110-
# $response.result.structuredContent.resources[$i].kind | Should -BeExactly $resources[$i].kind -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
111-
# $response.result.structuredContent.resources[$i].description | Should -BeExactly $resources[$i].description -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
112-
# }
113-
# }
103+
$response = Send-McpRequest -request $mcpRequest
104+
$response.id | Should -BeGreaterOrEqual 3
105+
$resources = dsc resource list | ConvertFrom-Json -Depth 20 | Select-Object type, kind, description -Unique
106+
$response.result.structuredContent.resources.Count | Should -Be $resources.Count
107+
for ($i = 0; $i -lt $resources.Count; $i++) {
108+
($response.result.structuredContent.resources[$i].psobject.properties | Measure-Object).Count | Should -BeGreaterOrEqual 3
109+
$response.result.structuredContent.resources[$i].type | Should -BeExactly $resources[$i].type -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
110+
$response.result.structuredContent.resources[$i].kind | Should -BeExactly $resources[$i].kind -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
111+
$response.result.structuredContent.resources[$i].description | Should -BeExactly $resources[$i].description -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
112+
}
113+
}
114114

115-
# It 'Calling list_dsc_resources with adapter works' {
116-
# $mcpRequest = @{
117-
# jsonrpc = "2.0"
118-
# id = 4
119-
# method = "tools/call"
120-
# params = @{
121-
# name = "list_dsc_resources"
122-
# arguments = @{
123-
# adapter = "Microsoft.DSC/PowerShell"
124-
# }
125-
# }
126-
# }
115+
It 'Calling list_dsc_resources with adapter works' {
116+
$mcpRequest = @{
117+
jsonrpc = "2.0"
118+
id = 4
119+
method = "tools/call"
120+
params = @{
121+
name = "list_dsc_resources"
122+
arguments = @{
123+
adapter = "Microsoft.DSC/PowerShell"
124+
}
125+
}
126+
}
127127

128-
# $response = Send-McpRequest -request $mcpRequest
129-
# $response.id | Should -Be 4
130-
# $resources = dsc resource list --adapter Microsoft.DSC/PowerShell | ConvertFrom-Json -Depth 20
131-
# $response.result.structuredContent.resources.Count | Should -Be $resources.Count
132-
# for ($i = 0; $i -lt $resources.Count; $i++) {
133-
# ($response.result.structuredContent.resources[$i].psobject.properties | Measure-Object).Count | Should -Be 4
134-
# $response.result.structuredContent.resources[$i].type | Should -BeExactly $resources[$i].type -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
135-
# $response.result.structuredContent.resources[$i].require_adapter | Should -BeExactly $resources[$i].require_adapter -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
136-
# $response.result.structuredContent.resources[$i].description | Should -BeExactly $resources[$i].description -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
137-
# }
138-
# }
128+
$response = Send-McpRequest -request $mcpRequest
129+
$response.id | Should -Be 4
130+
$resources = dsc resource list --adapter Microsoft.DSC/PowerShell | ConvertFrom-Json -Depth 20
131+
$response.result.structuredContent.resources.Count | Should -Be $resources.Count
132+
for ($i = 0; $i -lt $resources.Count; $i++) {
133+
($response.result.structuredContent.resources[$i].psobject.properties | Measure-Object).Count | Should -Be 4
134+
$response.result.structuredContent.resources[$i].type | Should -BeExactly $resources[$i].type -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
135+
$response.result.structuredContent.resources[$i].require_adapter | Should -BeExactly $resources[$i].require_adapter -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
136+
$response.result.structuredContent.resources[$i].description | Should -BeExactly $resources[$i].description -Because ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
137+
}
138+
}
139139

140-
# It 'Calling list_dsc_resources with <adapter> returns error' -TestCases @(
141-
# @{"adapter" = "Non.Existent/Adapter"},
142-
# @{"adapter" = "Microsoft.DSC.Debug/Echo"}
143-
# ) {
144-
# param($adapter)
140+
It 'Calling list_dsc_resources with <adapter> returns error' -TestCases @(
141+
@{"adapter" = "Non.Existent/Adapter"},
142+
@{"adapter" = "Microsoft.DSC.Debug/Echo"}
143+
) {
144+
param($adapter)
145145

146-
# $mcpRequest = @{
147-
# jsonrpc = "2.0"
148-
# id = 5
149-
# method = "tools/call"
150-
# params = @{
151-
# name = "list_dsc_resources"
152-
# arguments = @{
153-
# adapter = $adapter
154-
# }
155-
# }
156-
# }
146+
$mcpRequest = @{
147+
jsonrpc = "2.0"
148+
id = 5
149+
method = "tools/call"
150+
params = @{
151+
name = "list_dsc_resources"
152+
arguments = @{
153+
adapter = $adapter
154+
}
155+
}
156+
}
157157

158-
# $response = Send-McpRequest -request $mcpRequest
159-
# $response.id | Should -Be 5
160-
# $response.error.code | Should -Be -32602
161-
# $response.error.message | Should -Not -BeNullOrEmpty
162-
# }
158+
$response = Send-McpRequest -request $mcpRequest
159+
$response.id | Should -Be 5
160+
$response.error.code | Should -Be -32602
161+
$response.error.message | Should -Not -BeNullOrEmpty
162+
}
163163

164-
# It 'Calling show_dsc_resource works' {
165-
# $resource = (dsc resource list | Select-Object -First 1 | ConvertFrom-Json -Depth 20)
164+
It 'Calling show_dsc_resource works' {
165+
$resource = (dsc resource list | Select-Object -First 1 | ConvertFrom-Json -Depth 20)
166166

167-
# $mcpRequest = @{
168-
# jsonrpc = "2.0"
169-
# id = 6
170-
# method = "tools/call"
171-
# params = @{
172-
# name = "show_dsc_resource"
173-
# arguments = @{
174-
# type = $resource.type
175-
# }
176-
# }
177-
# }
167+
$mcpRequest = @{
168+
jsonrpc = "2.0"
169+
id = 6
170+
method = "tools/call"
171+
params = @{
172+
name = "show_dsc_resource"
173+
arguments = @{
174+
type = $resource.type
175+
}
176+
}
177+
}
178178

179-
# $response = Send-McpRequest -request $mcpRequest
180-
# $response.id | Should -Be 6
181-
# ($response.result.structuredContent.psobject.properties | Measure-Object).Count | Should -BeGreaterOrEqual 4
182-
# $because = ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
183-
# $response.result.structuredContent.type | Should -BeExactly $resource.type -Because $because
184-
# $response.result.structuredContent.kind | Should -BeExactly $resource.kind -Because $because
185-
# $response.result.structuredContent.version | Should -Be $resource.version -Because $because
186-
# $response.result.structuredContent.capabilities | Should -Be $resource.capabilities -Because $because
187-
# $response.result.structuredContent.description | Should -Be $resource.description -Because $because
188-
# $schema = (dsc resource schema --resource $resource.type | ConvertFrom-Json -Depth 20)
189-
# $response.result.structuredContent.schema.'$id' | Should -Be $schema.'$id' -Because $because
190-
# $response.result.structuredContent.schema.type | Should -Be $schema.type -Because $because
191-
# $response.result.structuredContent.schema.properties.keys | Should -Be $schema.properties.keys -Because $because
192-
# }
179+
$response = Send-McpRequest -request $mcpRequest
180+
$response.id | Should -Be 6
181+
($response.result.structuredContent.psobject.properties | Measure-Object).Count | Should -BeGreaterOrEqual 4
182+
$because = ($response.result.structuredContent | ConvertTo-Json -Depth 20 | Out-String)
183+
$response.result.structuredContent.type | Should -BeExactly $resource.type -Because $because
184+
$response.result.structuredContent.kind | Should -BeExactly $resource.kind -Because $because
185+
$response.result.structuredContent.version | Should -Be $resource.version -Because $because
186+
$response.result.structuredContent.capabilities | Should -Be $resource.capabilities -Because $because
187+
$response.result.structuredContent.description | Should -Be $resource.description -Because $because
188+
$schema = (dsc resource schema --resource $resource.type | ConvertFrom-Json -Depth 20)
189+
$response.result.structuredContent.schema.'$id' | Should -Be $schema.'$id' -Because $because
190+
$response.result.structuredContent.schema.type | Should -Be $schema.type -Because $because
191+
$response.result.structuredContent.schema.properties.keys | Should -Be $schema.properties.keys -Because $because
192+
}
193193

194-
# It 'Calling show_dsc_resource with non-existent resource returns error' {
195-
# $mcpRequest = @{
196-
# jsonrpc = "2.0"
197-
# id = 7
198-
# method = "tools/call"
199-
# params = @{
200-
# name = "show_dsc_resource"
201-
# arguments = @{
202-
# type = "Non.Existent/Resource"
203-
# }
204-
# }
205-
# }
194+
It 'Calling show_dsc_resource with non-existent resource returns error' {
195+
$mcpRequest = @{
196+
jsonrpc = "2.0"
197+
id = 7
198+
method = "tools/call"
199+
params = @{
200+
name = "show_dsc_resource"
201+
arguments = @{
202+
type = "Non.Existent/Resource"
203+
}
204+
}
205+
}
206206

207-
# $response = Send-McpRequest -request $mcpRequest
208-
# $response.id | Should -Be 7
209-
# $response.error.code | Should -Be -32602
210-
# $response.error.message | Should -Not -BeNullOrEmpty
211-
# }
207+
$response = Send-McpRequest -request $mcpRequest
208+
$response.id | Should -Be 7
209+
$response.error.code | Should -Be -32602
210+
$response.error.message | Should -Not -BeNullOrEmpty
211+
}
212212

213213
It 'Calling list_dsc_functions works' {
214214
$mcpRequest = @{

0 commit comments

Comments
 (0)