Comparison expressions don't evaluate operand type
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với việc tái hiện trong main_test.go và entry point awsutil.ValuesAtPath, sau đó theo dõi cách các biểu thức so sánh xử lý một toán hạng kiểu pointer đối với một literal. Bản sửa lỗi hoàn tất khi các trường hợp kiểm thử được nêu lần lượt trả về true, true/false và 2/1, đồng thời go test chạy thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Comparison expressions do not evaluate as expected in cases where one operand is a literal value and the other is a pointer to a value. This results in expressions such as AutoScalingGroups[].[length(Instances[?LifecycleState=='InService'] used in the AWS SDK for Go's Autoscaling waiter WaitUntilGroupInService not evaluating correctly since LifecycleState is a pointer to a string that is being evaluated against the literal string InService.
Steps to reproduce
Save this code as main_test.go and run go test -v:
package main
import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/service/autoscaling"
)
func TestWaitUntilGroupInService(t *testing.T) {
mockResponse := &autoscaling.DescribeAutoScalingGroupsOutput{
AutoScalingGroups: []*autoscaling.Group{
&autoscaling.Group{
Instances: []*autoscaling.Instance{
&autoscaling.Instance{
LifecycleState: aws.String("InService"),
},
&autoscaling.Instance{
LifecycleState: aws.String("InService"),
},
},
MaxSize: aws.Int64(4),
MinSize: aws.Int64(2),
DesiredCapacity: aws.Int64(2),
},
&autoscaling.Group{
Instances: []*autoscaling.Instance{
&autoscaling.Instance{
LifecycleState: aws.String("InService"),
},
&autoscaling.Instance{
LifecycleState: aws.String("Pending"),
},
},
MaxSize: aws.Int64(4),
MinSize: aws.Int64(2),
DesiredCapacity: aws.Int64(2),
},
},
}
var testCases = []struct {
expect []interface{}
data interface{}
path string
}{
{[]interface{}{true}, mockResponse, "contains(AutoScalingGroups[].[length(Instances[?LifecycleState=='InService']) >= MinSize][], `false`)"},
{[]interface{}{true, false}, mockResponse, "AutoScalingGroups[].[length(Instances[?LifecycleState=='InService']) >= MinSize][]"},
{[]interface{}{2, 1}, mockResponse, "AutoScalingGroups[].[length(Instances[?LifecycleState=='InService'])][]"},
}
for i, c := range testCases {
v, err := awsutil.ValuesAtPath(c.data, c.path)
if err != nil {
t.Errorf("case %v, expected no error, %v", i, c.path)
}
if e, a := c.expect, v; !awsutil.DeepEqual(e, a) {
t.Errorf("case %v, %v, expected: %#v, but got: %#v", i, c.path, e, a)
}
}
}
$ go get -u github.com/aws/aws-sdk-go
$ go test -v
=== RUN TestWaitUntilGroupInService
--- FAIL: TestWaitUntilGroupInService (0.00s)
main_test.go:59: case 0, contains(AutoScalingGroups[].[length(Instances[?LifecycleState=='InService']) >= MinSize][], `false`), expected: []interface {}{true}, but got: []interface {}{false}
main_test.go:59: case 1, AutoScalingGroups[].[length(Instances[?LifecycleState=='InService']) >= MinSize][], expected: []interface {}{true, false}, but got: []interface {}{}
main_test.go:59: case 2, AutoScalingGroups[].[length(Instances[?LifecycleState=='InService'])][], expected: []interface {}{2, 1}, but got: []interface {}{0, 0}
FAIL
exit status 1
FAIL _/Users/masayuki-morita/work/tmp/20190228 0.019s
Related items
Originating issue: https://github.com/aws/aws-sdk-go/issues/2478
Related to #15 and #20.
- Ngôn ngữ chính
- Go
- Star
- 623
- Fork
- 105
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của jmespath/go-jmespath
-
Possible error in lexer.goCó thể đã có người làm @AdamMagued đã nhận 52 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
jmespath/go-jmespath#97 ·
-
Does jmespath support maps?Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
jmespath/go-jmespath#96 · 1 bình luận ·
-
Can nested JSON string parsing be supported?Có thể đã có người làm @joerodriguez đã nhận 1047 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
jmespath/go-jmespath#91 ·
-
Filter of comparison works wrongĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
jmespath/go-jmespath#90 · 5 bình luận ·
-
Filtering objects by dateĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
jmespath/go-jmespath#85 · 1 bình luận ·
Tất cả issue của jmespath/go-jmespath
Issue tương tự
-
cmd/fix, x/tools/go/analysis/passes/modernize: mapsloop moves comments out of the range operandCó thể đã có người làm @muratmirgun đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Cojekt/LibreDental#258 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
cmd/podiomd: permission MCP stalls the turn when a tool input exceeds the 64KB scanner limitĐang mởgo good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
opensro-dev/opensro#4949 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 3 ngày