File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "ok" : false ,
3+ "error" : " invalid_auth"
4+ }
Original file line number Diff line number Diff line change 1+ {
2+ "ok" : true ,
3+ "url" : " https://subarachnoid.slack.com/" ,
4+ "team" : " Subarachnoid Workspace" ,
5+ "user" : " grace" ,
6+ "team_id" : " T12345678" ,
7+ "user_id" : " W12345678"
8+ }
Original file line number Diff line number Diff line change 1+ Clear-Host
2+ if (-not $PSScriptRoot ) {
3+ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
4+ }
5+ Import-Module - Name Pester - Force
6+ Import-Module .\Slack.Backup\Slack.Backup.psm1 - Force
7+
8+ Describe ' Test-Auth' {
9+ Context " Check token" {
10+ Mock Invoke-SlackAPI - ModuleName Slack.Backup {
11+ if ($Method -eq ' auth.test' ) {
12+ $file = " auth.test.error.json"
13+ if ($Token -eq " valid" ) {
14+ $file = " auth.test.ok.json"
15+ }
16+ Get-Content " .\Tests\MockData\$file " | ConvertFrom-Json
17+ }
18+ }
19+
20+ It " Given -Token '<Token>', it returns '<Expected>'" - TestCases @ (
21+ @ { Token = " invalid" ; Expected = $false }
22+ @ { Token = " valid" ; Expected = $true }
23+ ) {
24+ param ($Token , $Expected )
25+ Test-Auth - Token $Token - ErrorAction SilentlyContinue | Should - Be $Expected
26+ }
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments