added a very simple test suite

pull/73/head
Cooper Hammond 2020-11-08 01:17:45 -07:00
parent a8a1c4d1c3
commit 047cc71b0d
4 changed files with 39 additions and 11 deletions

View File

@ -1,9 +1,35 @@
require "./spec_helper"
describe Irs do
describe CLI do
# TODO: Write tests
it "works" do
false.should eq(true)
it "can show help" do
run_CLI_with_args(["--help"])
end
it "can show version" do
run_CLI_with_args(["--version"])
end
# !!TODO: make a long and short version of the test suite
# TODO: makes so this doesn't need user input
it "can install ytdl and ffmpeg binaries" do
# run_CLI_with_args(["--install"])
end
it "can show config file loc" do
run_CLI_with_args(["--config"])
end
it "can download a single song" do
run_CLI_with_args(["--song", "Bohemian Rhapsody", "--artist", "Queen"])
end
it "can download an album" do
run_CLI_with_args(["--artist", "Arctic Monkeys", "--album", "Da Frame 2R / Matador"])
end
it "can download a playlist" do
run_CLI_with_args(["--artist", "prakkillian", "--playlist", "IRS Testing"])
end
end

View File

@ -1,2 +1,10 @@
require "spec"
require "../src/irs"
# https://github.com/mosop/stdio
require "../src/bottle/cli"
def run_CLI_with_args(argv : Array(String))
cli = CLI.new(argv)
cli.act_on_args
end

View File

@ -73,22 +73,17 @@ class CLI
if @args["help"]? || @args.keys.size == 0
help
exit
elsif @args["version"]?
version
exit
elsif @args["install"]?
YdlBinaries.get_both(Config.binary_location)
exit
elsif @args["config"]?
puts ENV["IRS_CONFIG_LOCATION"]?
exit
elsif @args["song"]? && @args["artist"]?
s = Song.new(@args["song"], @args["artist"])
s.provide_client_keys(Config.client_key, Config.client_secret)
s.grab_it(@args["url"]?)
s.organize_it(Config.music_directory)
exit
elsif @args["album"]? && @args["artist"]?
a = Album.new(@args["album"], @args["artist"])
a.provide_client_keys(Config.client_key, Config.client_secret)
@ -108,7 +103,6 @@ class CLI
else
puts Style.red("Those arguments don't do anything when used that way.")
puts "Type `irs -h` to see usage."
exit 1
end
end

View File

@ -206,7 +206,7 @@ module Youtube
if yt_initial_data == JSON.parse("{}")
puts "Youtube has changed the way it organizes its webpage, submit a bug"
puts "on https://github.com/cooperhammond/irs"
puts "saying it has done so on https://github.com/cooperhammond/irs"
exit(1)
end