GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - awingeek/PSMatcher: PSMatcher is a test utility, that lets you easily test responses and json, when some part of the response is something out of your control (autogenerated id, guid, datetime etc). (And More)

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

22 Commits
22 Commits

Folders and files

NameName
Last commit message
Last commit date
Examples
Examples
 
 
classic
classic
 
 
dotnetcore
dotnetcore
 
 
images
images
 
 
InstallModule.ps1
InstallModule.ps1
 
 
LICENSE
LICENSE
 
 
PSMatcher.psd1
PSMatcher.psd1
 
 
PSMatcher.psm1
PSMatcher.psm1
 
 
PublishToGallery.ps1
PublishToGallery.ps1
 
 
README.md
README.md
 
 
readme.txt
readme.txt
 
 

Repository files navigation

PSMatcher

PSMatcher is a test utility, that lets you easier test responses and json, when some part of the response is something out of your control (autogenerated id, guid, datetime etc).

It's here on the PowerShell Gallery

Overview

This PowerShell has been tested on Windows in both v5.1 and v6.0

Import-Module ..\PSMatcher.psm1 -Force

$actual = @"
{
    "id" : "5a645a20-5225-431b-8c62-031b87f58b73",
    "subnode" : {
        "city" : "NY",
        "zipCode" : "80-000",
        "meta" : {
            "name" : "foobar",
            "shipping": 99.99,
            "enabled" : false,
            "_link" : "http://example.com?page=2",
            "_something" : null,
            "_arr" : [1, 2, 3],
            "_date" : "2018-01-01"
        }
    }
}
"@

$expected = @"
{
    "id" : "@guid@",
    "subnode" : {
        "city" : "NY",
        "zipCode" : "@string@",
        "meta" : {
            "name" : "@[email protected]('bar')",
            "shipping": "@double@",
            "enabled" : "@bool@",
            "_link" : "@any@",
            "_something" : "@null@",
            "_arr" : [1, 2, 3],
            "_date" : "@[email protected]()"
        }
    }
}
"@

Test-Json $actual $expected

Results

Successful ErrorMessage
---------- ------------
      True

In addition

The matcher also checks if elements are missing or if too many are supplied.

Stay Tuned: Examples will be added showing how well this works with PowerShell objects and Hashtables.

Available Expressions

  • @string@
  • @int@
  • @double@
  • @bool@
  • @null@
  • @any@
  • @guid@

Credits

This wraps NMatcher. Check out that readme for more detail.

About

PSMatcher is a test utility, that lets you easily test responses and json, when some part of the response is something out of your control (autogenerated id, guid, datetime etc). (And More)

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.