yaml-001

Tests that YAML can be parsed.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
   <p:output port="result"/>
   <p:identity>
      <p:with-input>
         <p:inline content-type="application/yaml">
name: build-pr
on:
  pull_request_target:
    types: [assigned, opened, edited, synchronize, reopened]
    branches:
      - main
          </p:inline>
      </p:with-input>
   </p:identity>
   <p:cast-content-type content-type="application/xml"/>
</p:declare-step>

Result

<map xmlns="http://www.w3.org/2005/xpath-functions"
     xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <string key="name">build-pr</string>
   <map key="on">
      <map key="pull_request_target">
         <array key="types">
            <string>assigned</string>
            <string>opened</string>
            <string>edited</string>
            <string>synchronize</string>
            <string>reopened</string>
         </array>
         <array key="branches">
            <string>main</string>
         </array>
      </map>
   </map>
</map>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:ns prefix="fn"
         uri="http://www.w3.org/2005/xpath-functions"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="fn:map">The result isn’t a map.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/fn:map">
         <s:assert test="fn:string[@key='name'] = 'build-pr'">The name is wrong.</s:assert>
         <s:assert test="fn:map[@key='on']">There’s no ‘on’ map.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/fn:map/fn:map[@key='on']">
         <s:assert test="fn:map[@key='pull_request_target']">There’s no pull request target map.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/fn:map/fn:map[@key='on']/fn:map[@key='pull_request_target']">
         <s:assert test="fn:array[@key='types']">There’s no types array.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

03 Jan 2025, Norm Tovey-Walsh
Created test.