Skip to content

Instantly share code, notes, and snippets.

@Andy-AO
Created May 31, 2021 05:25
Show Gist options
  • Save Andy-AO/da7c1076a247ecf7e698af18bbf33a0c to your computer and use it in GitHub Desktop.
Save Andy-AO/da7c1076a247ecf7e698af18bbf33a0c to your computer and use it in GitHub Desktop.
Behavioral testing for " describe-doc:fix a obscure error description in the git log documentation"
BeforeAll {
$PSSR = $PSScriptRoot
$TestGitRepoName = 'repo'
function ClearGitRepo {
Set-Location $PSSR
if ($TestGitRepoName | Test-Path) {
Remove-Item $TestGitRepoName -Recurse -Force
}
}
function InitGitRepo {
Set-Location $PSSR
git init $TestGitRepoName
Set-Location $TestGitRepoName
}
}
Describe 'Some information in Git log cannot be obtained' {
BeforeAll {
ClearGitRepo
InitGitRepo
$FileName = 'TEST.md'
'0' | ForEach-Object {
"line $_">$FileName
git add $FileName
git commit -m "r$_ mes"
git tag "s$_"
}
}
it 'By default, you cannot get the contents in brackets' {
Out-String -InputObject ((git log) *>&1) | Should -Not -BeLike '*(HEAD -> master, tag: s0)*'
}
it "Using auto can't get the content" {
Out-String -InputObject ((git log --decorate=auto) *>&1) | Should -Not -BeLike '*(HEAD -> master, tag: s0)*'
}
It "Explicitly specify '--decorate=short' to get the content in brackets" {
Out-String -InputObject ((git log --decorate=short) *>&1) | Should -BeLike '*(HEAD -> master, tag: s0)*'
}
it 'Use --decorate=full to get more information' {
Out-String -InputObject ((git log --decorate=full) *>&1) | Should -BeLike '*(HEAD -> refs/heads/master, tag: refs/tags/s0)*'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment