How to Unit Test a CLI in Go?

Поділитися
Вставка
  • Опубліковано 31 гру 2024

КОМЕНТАРІ • 5

  • @leoxvic4701
    @leoxvic4701 10 місяців тому +1

    ur experience shines thru ur tutorials; keep it up! thnx for the guidance

  • @andrewiglinski148
    @andrewiglinski148 Місяць тому

    This is awesome dude, but any ideas on how to make sure that flags and arguments are being handled properly? II'm brand new to Go, but I feel like I have a pretty decent grasp on it already, but for the life of me I can't figure out how to test my viper/cobra flag/args/env handling.

    • @andrewiglinski148
      @andrewiglinski148 Місяць тому

      Shit I'm an idiot... I should've waited until you got to the cmd.SetArgs function lol.

    • @GauravGahlotVideos
      @GauravGahlotVideos  28 днів тому

      @@andrewiglinski148 You should be able to set the flags in your unit tests, and the command should generate expected output.