1
0
mirror of https://github.com/Oxalide/vsphere-influxdb-go.git synced 2023-10-10 11:36:51 +00:00

add vendoring with go dep

This commit is contained in:
Adrian Todorov
2017-10-25 20:52:40 +00:00
parent 704f4d20d1
commit a59409f16b
1627 changed files with 489673 additions and 0 deletions

View File

@@ -0,0 +1,138 @@
(defconst testsuite-dir
(if load-file-name
(file-name-directory load-file-name)
;; Fall back to default directory (in case of M-x eval-buffer)
default-directory)
"Directory of the test suite.")
(defconst govc-test-helper-path
(concat (expand-file-name (concat testsuite-dir "/../../test/test_helper.bash"))))
(load (expand-file-name "../govc" testsuite-dir) nil :no-message)
(ert-deftest test-govc-url-parse ()
(dolist (u '("root:vagrant@localhost:18443"
"Administrator@vsphere.local:vagrant@localhost"
"https://root:vagrant@localhost:18443/sdk"
"https://Administrator@vsphere.local:vagrant@localhost/sdk"))
(should (equal u (url-recreate-url (govc-url-parse u))))))
(ert-deftest test-govc-session-set-url ()
(should (equal govc-session-insecure nil))
(should (equal govc-session-datacenter nil))
(with-temp-buffer
(govc-session-set-url "vc.example.com?insecure=true&datacenter=foo&ignored=true")
(should (equal govc-session-insecure "true"))
(should (equal govc-session-datacenter "foo"))
(should (equal govc-session-datastore nil))))
(ert-deftest test-govc-copy-environment ()
(let ((process-environment)
(govc-session-url "vc.example.com")
(govc-session-insecure "false")
(govc-session-datacenter "dc1")
(govc-session-datastore "ds1")
(govc-session-network "net1"))
(govc-export-environment '-)
(dolist (e govc-environment-map)
(should (equal nil (getenv (car e)))))
(govc-export-environment (universal-argument))
(dolist (e govc-environment-map)
(should (not (equal nil (getenv (car e))))))))
(defun govc-test-env ()
(let ((url (getenv "GOVC_TEST_URL")))
(unless url
(ert-skip "env GOVC_TEST_URL not set"))
(setq govc-session-url url
govc-session-insecure "true")))
(defun govc-test-helper (arg)
(shell-command-to-string (format "bash -c \"source %s; %s\"" govc-test-helper-path arg)))
(defun govc-test-new-vm ()
(s-trim-right (govc-test-helper "new_empty_vm")))
(defun govc-test-new-id ()
(s-trim-right (govc-test-helper "new_id")))
(defun govc-test-teardown ()
(ignore-errors
(govc-test-helper "teardown")))
(ert-deftest test-govc-vm-info ()
(govc-test-env)
(unwind-protect
(let ((id (govc-test-new-vm)))
(govc-json-info "vm.info" (list id))
(with-current-buffer "*govc-json*"
(goto-char (point-min))
(let ((data (json-read)))
(should (= (length data) 1))
(should (cdr (assq 'VirtualMachines data)))))
(govc-json-info "vm.info" (list "ENOENT"))
(with-current-buffer "*govc-json*"
(goto-char (point-min))
(let ((data (json-read)))
(should (= (length data) 1))
(should (not (cdr (assq 'VirtualMachines data))))))
(let ((govc-args (list id))
(len1)
(len2))
(setq len1 (length (govc-vm-extra-config)))
(should (>= len1 1))
(govc "vm.change" "-vm" id
"-e" "govc-test-one=1"
"-e" "govc-test-two:2.2=2"
;; test that we don't choke on \n
"-e" "foo=bar
baz")
(setq len2 (length (govc-vm-extra-config)))
(should (= (- len2 len1) 3)))
(let ((govc-filter "*"))
(should (>= (length (govc-vm-info)) 1)))
(let ((govc-filter "ENOENT"))
(should (= (length (govc-vm-info)) 0)))
(govc-vm-screen id))
(govc-test-teardown)))
(ert-deftest test-govc-datastore-ls-entries ()
(govc-test-env)
(unwind-protect
(let ((id (govc-test-new-id)))
(should (>= (length (govc-datastore-ls-entries)) 1))
(let ((govc-filter (concat id "/")))
(should-error (govc-datastore-ls-entries))
(govc "datastore.mkdir" id)
(should (= (length (govc-datastore-ls-entries)) 0))
(dotimes (i 3)
(govc "datastore.mkdir" (format "%s/dir %d" id i)))
(let ((entries (govc-datastore-ls-entries)))
(should (= (length entries) 3))
(should (s-starts-with? (concat id "/dir ") (caar entries))))))
(govc-test-teardown)))
(ert-deftest test-govc-pool-ls ()
(govc-test-env)
(unwind-protect
(let* ((pools (govc-ls-pool))
(num (length pools))
(path (concat (car pools) "/" (govc-test-new-id))))
(should (>= num 1))
(message "%d existing pools [%S]" num pools)
(govc "pool.create" path)
(setq pools (govc-ls-pool))
(govc-pool-destroy path)
(should (= (- (length pools) num) 1)))
(govc-test-teardown)))
(ert-deftest test-govc-about ()
(govc-test-env)
(govc "about"))

59
vendor/github.com/vmware/govmomi/govc/emacs/test/make.el generated vendored Executable file
View File

@@ -0,0 +1,59 @@
#!/usr/bin/env emacs --script
(let ((current-directory (file-name-directory load-file-name)))
(setq project-test-path (expand-file-name "." current-directory))
(setq project-root-path (expand-file-name ".." current-directory)))
(add-to-list 'load-path project-root-path)
(add-to-list 'load-path project-test-path)
(require 'lisp-mnt)
(require 'govc)
(require 's)
(defun make-test ()
(dolist (test-file (or argv (directory-files project-test-path t "-test.el$")))
(load test-file nil t))
(ert-run-tests-batch-and-exit t))
(defun govc-help ()
"Summary of govc modes in markdown format."
(interactive)
(with-help-window (help-buffer) ; TODO: this turned into a mess, but does the job of generating README.md from govc.el
(dolist (kind '(govc-mode govc-urls
govc-session-url govc-session-insecure govc-session-datacenter govc-session-datastore govc-session-network
tabulated-list host pool datastore datastore-ls vm device object metric))
(let* ((name (if (boundp kind) (symbol-name kind) (format "govc-%s-mode" kind)))
(map (if (equal 'govc-mode kind) 'govc-command-map (intern (concat name "-map"))))
(doc (lambda (f &optional all)
(let* ((txt (if (functionp f) (documentation f t) (documentation-property f 'variable-documentation)))
(ix (if all (length txt) (s-index-of "." txt))))
(s-replace (format "\n\n\\\{%s\}" (concat name "-map")) ""
(s-replace "'" "`" (substring txt 0 ix)))))))
(princ (concat (s-repeat (if (and (boundp kind) (not (fboundp kind))) 3 2) "#") " " name "\n"))
(princ (concat "\n" (funcall doc (intern name) t) "\n\n"))
(when (boundp map)
(princ (concat "### " (symbol-name map) "\n\n"))
(princ "Keybinding | Description\n")
(princ "---------------|------------------------------------------------------------\n")
(dolist (kl (govc-keymap-list (symbol-value map)))
(let ((key (govc-key-description (car kl))))
(princ (format "<kbd>%s</kbd>%s| %s\n" key (s-repeat (- 4 (length key)) " ") (funcall doc (nth 2 kl))))))
(princ "\n"))))))
(defun make-docs ()
(let ((commentary)
(summary))
(with-current-buffer (find-file-noselect (concat project-root-path "/govc.el"))
(setq commentary (s-replace ";;; Commentary:" "" (lm-commentary))
summary (lm-summary)))
(let ((readme (find-file-noselect (concat project-root-path "/README.md"))))
(with-current-buffer readme
(erase-buffer)
(govc-help)
(with-current-buffer (help-buffer)
(copy-to-buffer readme (point-min) (point-max)))
(goto-char (point-min))
(insert (concat "# govc.el\n\n" summary ".\n"))
(insert (s-replace "'" "`" (replace-regexp-in-string ";; ?" "" commentary t t)))
(save-buffer 0)))))