我想测试REST API如何处理具有无效JSON语法的主体的POST请求,例如缺少逗号.我正在使用node.js编写API测试.我正在使用frisby,但我也尝试了超级.没运气.使用以前的工具,您将请求主体作为JavaScript对象传递,因此不行.我还尝试将无效的JSON作为字符串传递而没有任何运气,因为字符串也是有效的JSON(下面的示例).有任何想法吗?
frisby.create('Ensure response has right status')
.post('http://example.com/api/books', '{"invalid"}', {json: true})
.expectStatus(400)
.toss();
Run Code Online (Sandbox Code Playgroud) 我想构建和应用程序,用户可以通过它来输入一些设置,应用程序将启动后台服务以根据这些设置执行某些任务.我想只在模拟器中运行应用程序和后台服务(我知道它需要"认证"模式来运行后台服务,但我现在不想在Firefox Marketplace上发布应用程序).
有人可以提供一些关于如何在FIrefox OS平台上构建和运行后台服务的链接或教程吗?任何人都可以解释如何在后台服务和应用程序之间进行通信吗?(我搜索了MDN和谷歌,但没有运气).
此外,应用程序(常规应用程序或后台服务)是否有某种方式来监听来自服务器的通知?(我正在寻找一种方法,其中应用程序不会汇集,但会被服务器通知).
谢谢你,Tamash
我尝试用流浪汉创建简单的开发环境但是在postgres中遇到问题.
我的Vagrantfile很简单:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network :public_network
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
end
Run Code Online (Sandbox Code Playgroud)
我使用ansible提供:
- name: Configure development machine
hosts: all
sudo: True
tasks:
- name: install postgres
apt: name={{ item }} update_cache=yes
with_items:
- postgresql
- postgresql-contrib
Run Code Online (Sandbox Code Playgroud)
但出了问题,postgres安装不正确
当我ssh到VM,我看到奇怪的事情:
$ /etc/init.d/postgresql start …Run Code Online (Sandbox Code Playgroud) javascript ×2
ansible ×1
background ×1
distutils ×1
firefox ×1
firefox-os ×1
frisby.js ×1
json ×1
mobile ×1
node.js ×1
postgresql ×1
pypi ×1
python ×1
setuptools ×1
superagent ×1
ubuntu-14.04 ×1
vagrant ×1