DraconCreditTest.kt
/**
* Dracon - An IntelliJ-Pijul integration.
* Copyright 2021 JonathanxD <jhrldev@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.jonathanxd.dracon.test
import com.github.jonathanxd.dracon.log.*
import com.github.jonathanxd.dracon.pijul.credit.parseCredit
import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.shouldBe
import java.time.ZoneOffset
import java.time.ZonedDateTime
class DraconCreditTest : ShouldSpec({
should("correctly parse a 'pijul credit' text with example credit") {
val text = """
GGYFPXND4VBCQ
NTRPUMVQHUIQY
> #
> # Dracon - An IntelliJ-Pijul integration.
> # Copyright 2021 JonathanxD <jhrldev@gmail.com>
> #
> # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
> #
> # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
> #
> # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #
>
GGYFPXND4VBCQ, NTRPUMVQHUIQY
> dracon.vcs.name=Pijul
> dracon.vcs.name.with.mnemonic=_Pijul
Q7FXTHVUPVAFM
>
GGYFPXND4VBCQ, Q7FXTHVUPVAFM
>
MTPTFTHGAOKQG
> action.Pijul.Init.text=Create Pijul Repository
> action.Pijul.Add.text=Add Files...
ZCRW57C5MSBXY
> action.Pijul.ExpertRecord.text=Record (Expert Mode)...
2N67RQZCVGL6G
> action.Pijul.InvalidateCaches.text=Invalidate Caches
ZCRW57C5MSBXY, 2N67RQZCVGL6G, MTPTFTHGAOKQG
> action.Pijul.Commit.And.Push.text=Commit And Push...
GGYFPXND4VBCQ, MTPTFTHGAOKQG
> init.title=Create Pijul Repository
> init.description=Select the target directory to init Pijul repository.
> init.warning.title=Pijul Init
> init.warning.already.under.pijul=The directory <tt>{0}</tt> is already under Pijul.\n\
Q7FXTHVUPVAFM, MTPTFTHGAOKQG
> Are you sure that you want to create a new VCS root?
> init.error=Failed to initialize Pijul repository.
>
> dracon.refresh=Refreshing Pijul Repository
>
ZCRW57C5MSBXY, Q7FXTHVUPVAFM
> group.Pijul.Menu.text=_Pijul
>
> record.action.name=Record
ZCRW57C5MSBXY, 2N67RQZCVGL6G
> record.author=&Author:
> record.expert.mode.title=Record (Expert Mode)
>
> expert.mode.button.record=Record
> expert.mode.button.cancel=Cancel
>
> expert.mode.notification.group.id=Expert mode
> expert.mode.notification.title=Record (expert mode)
> expert.mode.notification.success=Successfully recorded changes. New revision: <tt>{0}</tt>.
2N67RQZCVGL6G
> expert.mode.notification.failure=Failed to record changes with exit code <bold>{0}</bold> and message: <tt>{1}</tt>.
>
> cache.invalidate.text=Invalidating caches...
> cache.invalidate.current.text=Invalidating <em>{0}</em>...
> cache.invalidate.finish.text=Invalidated caches
>
> install.pijul.title=Install pijul
> install.pijul.title2=Install Pijul
> install.pijul.text=Cannot find pijul binaries.\n\
> Do you want to install pijul using rust cargo?
>
> install.editor.server.title=Install editor-server
> install.editor.server.title2=Install Editor Server
> install.editor.server.text=Cannot find editor-server binaries.\n\
> Dracon depends on editor-server for interfacing with Pijul.\n\
> Do you want to install editor-server using rust cargo?
>
> install.cargo.title=Install Rustup and Cargo
> install.cargo.text=In order to install <tt>{0}</tt> you need to have cargo installed.\n\
> However we cannot find cargo installed in this machine.\n\
> Do you want to install rustup with cargo?\n\
> If you agree, we will download rustup and launch the installer, you take from there.
>
> install.pijul.warning.text=You won't be able to use Dracon plugin since some dependencies could not be installed.
>
> install.cargo.running.text=Running cargo install...
""".trimIndent()
val credit = text.parseCredit()
credit.toString() shouldBe "PijulCredit(header=[GGYFPXND4VBCQ], entries=[PijulCreditEntry(shortHash=[NTRPUMVQHUIQY], data=[#, # Dracon - An IntelliJ-Pijul integration., # Copyright 2021 JonathanxD <jhrldev@gmail.com>, #, # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, #, # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., #, # THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., #, ]), PijulCreditEntry(shortHash=[GGYFPXND4VBCQ, NTRPUMVQHUIQY], data=[dracon.vcs.name=Pijul, dracon.vcs.name.with.mnemonic=_Pijul]), PijulCreditEntry(shortHash=[Q7FXTHVUPVAFM], data=[]), PijulCreditEntry(shortHash=[GGYFPXND4VBCQ, Q7FXTHVUPVAFM], data=[]), PijulCreditEntry(shortHash=[MTPTFTHGAOKQG], data=[action.Pijul.Init.text=Create Pijul Repository, action.Pijul.Add.text=Add Files...]), PijulCreditEntry(shortHash=[ZCRW57C5MSBXY], data=[action.Pijul.ExpertRecord.text=Record (Expert Mode)...]), PijulCreditEntry(shortHash=[2N67RQZCVGL6G], data=[action.Pijul.InvalidateCaches.text=Invalidate Caches]), PijulCreditEntry(shortHash=[ZCRW57C5MSBXY, 2N67RQZCVGL6G, MTPTFTHGAOKQG], data=[action.Pijul.Commit.And.Push.text=Commit And Push...]), PijulCreditEntry(shortHash=[GGYFPXND4VBCQ, MTPTFTHGAOKQG], data=[init.title=Create Pijul Repository, init.description=Select the target directory to init Pijul repository., init.warning.title=Pijul Init, init.warning.already.under.pijul=The directory <tt>{0}</tt> is already under Pijul.\\n\\]), PijulCreditEntry(shortHash=[Q7FXTHVUPVAFM, MTPTFTHGAOKQG], data=[ Are you sure that you want to create a new VCS root?, init.error=Failed to initialize Pijul repository., , dracon.refresh=Refreshing Pijul Repository, ]), PijulCreditEntry(shortHash=[ZCRW57C5MSBXY, Q7FXTHVUPVAFM], data=[group.Pijul.Menu.text=_Pijul, , record.action.name=Record]), PijulCreditEntry(shortHash=[ZCRW57C5MSBXY, 2N67RQZCVGL6G], data=[record.author=&Author:, record.expert.mode.title=Record (Expert Mode), , expert.mode.button.record=Record, expert.mode.button.cancel=Cancel, , expert.mode.notification.group.id=Expert mode, expert.mode.notification.title=Record (expert mode), expert.mode.notification.success=Successfully recorded changes. New revision: <tt>{0}</tt>.]), PijulCreditEntry(shortHash=[2N67RQZCVGL6G], data=[expert.mode.notification.failure=Failed to record changes with exit code <bold>{0}</bold> and message: <tt>{1}</tt>., , cache.invalidate.text=Invalidating caches..., cache.invalidate.current.text=Invalidating <em>{0}</em>..., cache.invalidate.finish.text=Invalidated caches, , install.pijul.title=Install pijul, install.pijul.title2=Install Pijul, install.pijul.text=Cannot find pijul binaries.\\n\\, Do you want to install pijul using rust cargo?, , install.editor.server.title=Install editor-server, install.editor.server.title2=Install Editor Server, install.editor.server.text=Cannot find editor-server binaries.\\n\\, Dracon depends on editor-server for interfacing with Pijul.\\n\\, Do you want to install editor-server using rust cargo?, , install.cargo.title=Install Rustup and Cargo, install.cargo.text=In order to install <tt>{0}</tt> you need to have cargo installed.\\n\\, However we cannot find cargo installed in this machine.\\n\\, Do you want to install rustup with cargo?\\n\\, If you agree, we will download rustup and launch the installer, you take from there., , install.pijul.warning.text=You won't be able to use Dracon plugin since some dependencies could not be installed., , install.cargo.running.text=Running cargo install...])])"
}
})