From 7f3185eb04e0740618847cbbefe0b8d6f2115df0 Mon Sep 17 00:00:00 2001 From: jysperm Date: Fri, 30 May 2014 14:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=20API=20=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 -- TEST/API/account_spec.coffee | 73 ------------------------------- TEST/API/init.coffee | 83 ------------------------------------ TEST/API/plan_spec.coffee | 10 ----- TEST/API/ticket_spec.coffee | 79 ---------------------------------- run-test.bash | 8 ---- 6 files changed, 256 deletions(-) delete mode 100644 TEST/API/account_spec.coffee delete mode 100644 TEST/API/init.coffee delete mode 100644 TEST/API/plan_spec.coffee delete mode 100644 TEST/API/ticket_spec.coffee delete mode 100644 run-test.bash diff --git a/Makefile b/Makefile index e00b927..b5a2eb6 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,6 @@ install: build: install node node_modules/coffee-script/bin/coffee -c . -test: build - bash run-test.bash - clean: find . -path './node_modules' -prune -o -name '*.js' -exec rm -fr {} \; diff --git a/TEST/API/account_spec.coffee b/TEST/API/account_spec.coffee deleted file mode 100644 index 8ec4308..0000000 --- a/TEST/API/account_spec.coffee +++ /dev/null @@ -1,73 +0,0 @@ -frisby = require 'frisby' - -config = require '../../core/config' - -baseUrl = "http://127.0.0.1:#{config.web.port}" - -frisby.create '/account/signup/' - .post "#{baseUrl}/account/signup/", - username: 'test' - email: 'test@jysperm.me' - passwd: 'password' - .expectStatus 200 - .expectJSONTypes - id: String - .toss() - -frisby.create '/account/signup email_exist' - .post "#{baseUrl}/account/signup/", - username: 'test2' - email: 'test@jysperm.me' - passwd: 'password' - .expectStatus 400 - .expectJSON - error: 'email_exist' - .toss() - -frisby.create '/account/login/' - .post "#{baseUrl}/account/login/", - username: 'test@jysperm.me', - passwd: 'password' - .expectStatus 200 - .expectJSONTypes - id: String - token: String - .toss() - -frisby.create '/account/login/' - .post "#{baseUrl}/account/login/", - username: 'test', - passwd: 'password' - .expectStatus 200 - .expectJSONTypes - id: String - token: String - .toss() - -frisby.create '/account/logout/' - .post "#{baseUrl}/account/logout/", {}, - headers: - 'x-token': 'need_be_remove' - .expectStatus 200 - .toss() - -frisby.create '/account/logout/ auth_failed' - .post "#{baseUrl}/account/logout/", {}, - headers: - 'x-token': 'token_not_exist' - .expectStatus 400 - .expectJSON - error: 'auth_failed' - .toss() - -frisby.globalSetup - request: - headers: - 'x-token': 'token' - -frisby.create '/account/update_passwd/' - .post "#{baseUrl}/account/update_passwd/", - old_passwd: 'password', - new_passwd: '123123' - .expectStatus 200 - .toss() diff --git a/TEST/API/init.coffee b/TEST/API/init.coffee deleted file mode 100644 index b3a7054..0000000 --- a/TEST/API/init.coffee +++ /dev/null @@ -1,83 +0,0 @@ -async = require 'async' - -db = require '../../core/db' - -module.exports = (callback) -> - cAccount = db.collection 'accounts' - cTicket = db.collection 'tickets' - - async.parallel [ - (callback) -> - cAccount.remove - username: $in: ['test', 'test_main'] - , callback - - (callback) -> - cAccount.remove - email: 'test@jysperm.me' - , callback - - (callback) -> - cAccount.insert - _id: db.ObjectID '533b0cb894f6c673123e33a3' - - username: 'test_main' - passwd: '9de9bb1f01888f4cf6c32cd02c6ad2b15804b292947552324ae8f7d52e12714c' - passwd_salt: '9499537d1f65ae43e7ac4d1c2901bb7647ac735b5b9b6c9eea945d8453c3636f' - email: 'test_main@jysperm.me' - singup_at: new Date() - - group: ['root'] - setting: {} - attribute: {} - - tokens: [ - { - token: 'token' - available: true - created_at: new Date() - updated_at: new Date() - - attribute: {} - }, - { - token: 'need_be_remove' - available: true - created_at: new Date() - updated_at: new Date() - - attribute: {} - } - ] - , callback - - (callback) -> - cTicket.remove - account_id: db.ObjectID '533b0cb894f6c673123e33a3' - , callback - - (callback) -> - cTicket.insert - _id: db.ObjectID '533b0cb894f6c673123e33a4' - account_id: db.ObjectID '533b0cb894f6c673123e33a3' - created_at: new Date() - updated_at: new Date() - title: 'Ticket Title' - content: 'Ticket Content(Markdown)' - content_html: 'Ticket Conetnt(HTML)' - type: 'linux' - status: 'open' - members: [ - db.ObjectID '533b0cb894f6c673123e33a3' - ] - attribute: {} - replys: [] - , callback - - ], -> - callback() - -unless module.parent - db.connect -> - module.exports -> - process.exit() diff --git a/TEST/API/plan_spec.coffee b/TEST/API/plan_spec.coffee deleted file mode 100644 index 2018bd7..0000000 --- a/TEST/API/plan_spec.coffee +++ /dev/null @@ -1,10 +0,0 @@ -frisby = require 'frisby' - -config = require '../../core/config' - -baseUrl = "http://127.0.0.1:#{config.web.port}" - -frisby.globalSetup - request: - headers: - 'x-token': 'token' diff --git a/TEST/API/ticket_spec.coffee b/TEST/API/ticket_spec.coffee deleted file mode 100644 index 7134dae..0000000 --- a/TEST/API/ticket_spec.coffee +++ /dev/null @@ -1,79 +0,0 @@ -frisby = require 'frisby' - -config = require '../../core/config' - -baseUrl = "http://127.0.0.1:#{config.web.port}" - -frisby.globalSetup - request: - headers: - 'x-token': 'token' - -frisby.create '/ticket/create/' - .post "#{baseUrl}/ticket/create/", - title: 'Ticket Title' - content: 'Ticket Content(Markdown)' - type: 'linux' - .expectStatus 200 - .expectJSONTypes - id: String - .toss() - -frisby.create '/ticket/create/ invalid_type' - .post "#{baseUrl}/ticket/create/", - title: 'Ticket Title' - content: 'Ticket Content(Markdown)' - type: 'type_not_exist' - .expectStatus 400 - .expectJSON - error: 'invalid_type' - .toss() - -frisby.create '/ticket/create/' - .post "#{baseUrl}/ticket/create/", - title: 'Ticket Title' - content: 'Ticket Content(Markdown)' - type: 'linux' - members: ['test'] - .expectStatus 200 - .expectJSONTypes - id: String - .toss() - -frisby.create '/ticket/reply/' - .post "#{baseUrl}/ticket/reply/", - id: '533b0cb894f6c673123e33a4' - content: 'Reply Content(Markdown)' - .expectStatus 200 - .expectJSONTypes - id: String - .toss() - -frisby.create '/ticket/update/' - .post "#{baseUrl}/ticket/update/", - id: '533b0cb894f6c673123e33a4' - type: 'nodejs' - status: 'closed' - .expectStatus 200 - .toss() - -frisby.create '/ticket/update/' - .post "#{baseUrl}/ticket/update/", - id: '533b0cb894f6c673123e33a4' - attribute: - public: true - .expectStatus 200 - .toss() - -frisby.create '/ticket/list/' - .post "#{baseUrl}/ticket/list/", - status: 'open' - .expectStatus 200 - .expectJSON '*', - status: 'open' - .expectJSONTypes '*', - id: String - title: String - type: String - updated_at: String - .toss() diff --git a/run-test.bash b/run-test.bash deleted file mode 100644 index 8f230a2..0000000 --- a/run-test.bash +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -node node_modules/coffee-script/bin/coffee app.coffee & -sleep 1s -SERVER_PID="$!" -node node_modules/coffee-script/bin/coffee TEST/API/init.coffee -node node_modules/jasmine-node/bin/jasmine-node --junitreport TEST/API -kill "$SERVER_PID"