我已经使用AWS sam本地设置了api gateway/aws lambda对,并确认我可以在运行后成功调用它
sam local start-api
然后我在docker容器中添加了一个本地dynamodb实例,并使用aws cli在其上创建了一个表
但是,将代码添加到lambda以写入我收到的dynamodb实例:
2018-02-22T11:13:16.172Z ed9ab38e-fb54-18a4-0852-db7e5b56c8cd错误:无法写入表:{"message":"connect ECONNREFUSED 0.0.0.0:8000","code":"NetworkingError", "错误号": "ECONNREFUSED", "系统调用": "连接", "地址": "0.0.0.0", "端口":8000, "区": "EU-西-2", "主机名":"0.0 .0.0","retryable":true,"time":"2018-02-22T11:13:16.165Z"}从命令写入事件:{"name":"test","geolocation":"xyz","输入":"createDestination"} END RequestId:ed9ab38e-fb54-18a4-0852-db7e5b56c8cd
我在网上看到你可能需要连接到同一个docker网络,所以我创建了一个网络docker network create lambda-local并将我的启动命令更改为:
sam local start-api --docker-network lambda-local
和
docker run -v "$PWD":/dynamodb_local_db -p 8000:8000 --network=lambda-local cnadiminti/dynamodb-local:latest
但仍然收到相同的错误
山姆本地打印出来 2018/02/22 11:12:51 Connecting container 98b19370ab92f3378ce380e9c840177905a49fc986597fef9ef589e624b4eac3 to network lambda-local
我正在使用以下方法创建dynamodbclient:
const AWS = require('aws-sdk')
const dynamodbURL = process.env.dynamodbURL || 'http://0.0.0.0:8000'
const awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID || '1234567'
const awsAccessKey = process.env.AWS_SECRET_ACCESS_KEY || '7654321' …Run Code Online (Sandbox Code Playgroud) 我已经设置了一些使用Mocha显示表的React组件的测试.我可以在其初始状态断言,但我有一个点击事件,它对我要测试的数据进行排序.
如果我React.addons.TestUtils.Simulate.click(theComponent)用来尝试测试排序.
setState 但是当我对组件断言时,没有任何改变.
it('sorts the data when the year header is clicked', function() {
var React = require('react/addons');
var TestUtils = React.addons.TestUtils;
var payTable = TestUtils.renderIntoDocument(
<PayTable payYears={data} />
);
var headers = TestUtils.scryRenderedDOMComponentsWithTag(payTable, 'th');
var yearHeader = headers[0];
TestUtils.Simulate.click(yearHeader.getDOMNode());
var columnValues = getYearColumnValues(payTable, TestUtils);
columnValues.should.match([ 'Year', '1066', '1067', '1068' ]);
});
Run Code Online (Sandbox Code Playgroud)
我需要强制更新吗?重新阅读组件?
该代码可在Github上获得.
我可以测试Component的其他方面,但不能测试Component值 setState
所以我们有一个取消订阅链接 - 这本质上是HTTP GET.
在适当的RFC说,这应该是幂等的,但在我看来,用户的预期将是他们点击一个链接来采取行动.
我已经实现了这一点,以便链接将您带到一个具有大确认按钮的页面,然后更新您的订阅,确认并显示您帐户的最终状态(我们有多种类型的订阅)
但我想知道如果这个人只是跳过确认按钮阶段它不会是一个更好的用户体验......
问题的答案"我是否过度思考这个问题?" 肯定是的,但我想知道人们对平衡幂等GET的最佳实践与不混淆用户期望的最佳实践的看法......
我的目标是Google API 2.3.3并拥有以下测试类
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.provider.Settings;
import android.test.AndroidTestCase;
import android.util.Log;
public class MockLocationManagerTests extends AndroidTestCase implements LocationListener{
private static final String TAG = "MockLocationTests";
private String locationProvider = "TestProvider";
private LocationManager locationManager;
private Location lastLocation;
protected void setUp() throws Exception {
super.setUp();
locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
if (Settings.Secure.getInt(getContext().getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION, 0) == 0) {
fail("Mock location must be enabled");
}
setupLocationManager();
}
private void setupLocationManager() {
if (locationManager.getProvider(locationProvider) …Run Code Online (Sandbox Code Playgroud) 例如,如果我有以下代码:
var nodaStart = new LocalDate(2012, 5, 1);
var nodaEnd = new LocalDate(2012,5,2);
var daysBetween = Period.Between(nodaStart, nodaEnd,PeriodUnits.Day);
Run Code Online (Sandbox Code Playgroud)
然后 daysBetween.Days == 1
但是,我计算的范围需要计算为2天.即它需要包括开始和结束日期.
实际的方法可以采取开始和结束日期(相隔不超过一年),并需要计算天数.如果超过31天,则剩余的数量将返回整周.
我有那种逻辑工作正常,但因为计数是独家我有一天出去了.
我想我可以startDate.addDays(-1)在创建nodaStart它之前做,但我想知道是否有更优雅/漂亮的方式让noda返回Period.
谢谢
更新:我已经阅读了类的源代码,Period并且+运算符被重载,所以我可以添加
daysBetween += Period.FromDays(1);
Run Code Online (Sandbox Code Playgroud) 我想使用FluentValidation来验证一些类,其中一个类仅用作另一个类的属性......但我从不直接创建子类,所以我想从父级别测试验证.这可能是不必要的/疯狂的
所以我举个例子
public class Parent
{
public string Text {get;set;}
public Child Child {get;set;}
}
public class Child
{
public string Text {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
和
public class ParentValidator : AbstractValidator<Parent>
{
public ParentValidator()
{
RuleFor(p=>p.Text).NotEmpty();
//RuleFor(p=>p.Child).SetValidator(new ChildValidator);
//RuleFor(p=>p.Child.Text).NotEmpty();
}
}
public class ChildValidator : AbstractValidator<Child>
{
public ChildValidator()
{
RuleFor(c=>c.Text).NotEmpty();
}
}
Run Code Online (Sandbox Code Playgroud)
我测试使用
[Test]
public void ParentMustHaveText()
{
new ParentValidator()
.ShouldHaveValidationErrorFor(p => p.Text, "");
}
[Test]
public void ChildMustHaveText()
{
new ParentValidator().ShouldHaveValidationErrorFor(p => p.Child.Text, "");
}
Run Code Online (Sandbox Code Playgroud)
ChildMustHaveText无论我如何设置,测试总是失败.我是否疯狂试图以这种方式进行测试?
因为以下测试总是通过
[Test] …Run Code Online (Sandbox Code Playgroud) 节点noob问题在这里我很确定.
我在一个简单的快速JS应用程序中有以下代码
var randomPin = require('./api/randomPin');
var currentPin = "pin";
app.post('/match', function(req, res) {
if (req.body.pin && req.body.pin == currentPin) {
//it should only be possible for one person to get here
//and receive this hurrah
currentPin = randomPin.generate();
res.send({hurrah:true});
}
res.send({hurrah:false});
});
Run Code Online (Sandbox Code Playgroud)
我仍然没有理解Node请求的工作流程......
是否有可能出现竞争条件,其中两个帖子请求/match同时被处理,以便两个帖子都试图呼叫randomPin.generate()?
如果是这样,有一个避免这种情况的"最佳方式"?
我希望能够通过 JSTS 未能构建它们或通过添加缓冲区并在缓冲后测试它们是否是 MultiPolygons 来测试自相交多边形,但对于某些形状,这不起作用,这远远超出了我的几何能力格罗克
//a self-intersecting shape
var poly = [[0, 3], [1, 5], [3, 1], [5, 5], [6, 3], [0, 3]];
var geomFactory = new jsts.geom.GeometryFactory();
var jstsCoordinates = poly.map(function(pt) {
return new jsts.geom.Coordinate(pt[0], pt[1]);
});
var linearRing = geomFactory.createLinearRing(jstsCoordinates);
var jstsPolygon = geomFactory.createPolygon(linearRing).buffer(1);
console.log(jstsPolygon.getGeometryType()); //this will be polygon but I thought should be MultiPolygon
var bufferedPoly = (jstsPolygon.shell.points.coordinates.map(function(pr) {
return [pr.x, pr.y]
}))
var svg = d3.select('svg');
//add the first shape (maginified for display)
svg.selectAll('.original').data([poly]).enter().append("polygon")
.attr("points",function(d) { …Run Code Online (Sandbox Code Playgroud)我已经提供了一个新的Server 2012框来进行设置.
我正在尝试使用powershell来安装chocolatey
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
并得到错误
Exception calling "DownloadString" with "1" argument(s): "The underlying connection was closed: An unexpected error
occurred on a receive."
At line:1 char:1
+ iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/in ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
我可以在浏览器中访问该URL.
起初我认为这与Chocolatey有关,但后来我才意识到这一点
(New-Object System.Net.WebClient).DownloadString('http://google.com'))
可以下载HTML内容
但
((New-Object System.Net.WebClient).DownloadString('https://google.com'))
失败并出现同样的错误
The underlying connection was closed: An unexpected error occurred on a receive.
盒子:
我确信我做的事情很傻但看不出来......
---更新---
基于 …
我有一个在Jenkins项目中构建的ASP .NET MVC项目.我们正在使用nUnit插件来破坏我们的单元测试的输出,作为构建后的步骤.
我刚刚为项目中的javascript添加了Jasmine测试,并在MSBuild中添加了一个步骤,让Chutzpah运行Jasmine测试并以jUnit格式输出结果.

我添加了一个post build步骤来处理jUnit结果文件,Jenkins运行构建并在Build result页面中显示两个'Test Results'链接...

但是,当我单击这些链接时,两者都会得到相同的结果.当我昨天离开时,今天早上的nUnit结果是jUnit结果,所以我猜它是最后一个完成的?
这可能吗?我需要以不同的方式做事吗?