ruby: add a gem that wraps the library

This commit is contained in:
James Tucker
2023-03-01 17:38:45 -08:00
parent 0f378c01bd
commit 775ee41f1d
13 changed files with 498 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
# Copyright (c) Tailscale Inc & AUTHORS
# SPDX-License-Identifier: BSD-3-Clause
# frozen_string_literal: true
require 'test_helper'
class TestTailscale < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Tailscale::VERSION
end
def test_listen_sorta_works
# TODO: make a more useful test when we can make a client to connect with.
ts = newts
ts.start
s = ts.listen "tcp", ":1999"
s.close
ts.close
end
def test_dial_sorta_works
# TODO: make a more useful test when we can make a server to connect to.
ts = newts
ts.start
c = ts.dial "udp", "100.100.100.100:53", ""
c.close
ts.close
end
def newts
t = Tailscale::new
unless ENV['VERBOSE']
logfd = IO.sysopen("/dev/null", "w+")
t.set_log_fd logfd
end
t
end
end

6
ruby/test/test_helper.rb Normal file
View File

@@ -0,0 +1,6 @@
# Copyright (c) Tailscale Inc & AUTHORS
# SPDX-License-Identifier: BSD-3-Clause
# frozen_string_literal: true
require "tailscale"
require "minitest/autorun"