Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonconfig.Obj.int functions are actually checking for floats #27

Open
stephens2424 opened this issue Feb 5, 2017 · 3 comments
Open

Comments

@stephens2424
Copy link

Found while writing a test for github.com/perkeep/perkeep/issues/443. I was getting the error

    proxycache_test.go:259: Expected config key "maxCacheBytes" to be a number

whether I was passing an untyped number literal or an int64 directly. The test code looks like:

        const maxBytes int64 = 1 << 5
        px, ds := NewProxiedDisk(t)

        ld := test.NewLoader()
        ld.SetStorage("origin", ds) 
        ld.SetStorage("cache", px) 

        cache, err := newFromConfig(ld, jsonconfig.Obj{
                "origin":        "origin",
                "cache":         "cache",
                "maxCacheBytes": maxBytes,
        })

After I tweaked this code, it was fine. PR forthcoming

@stephens2424
Copy link
Author

@mpl
Copy link
Contributor

mpl commented Feb 6, 2017

I think that float64 particularity of JSON got me confused enough once too that I also proposed that sort of a change. Since that now makes two of us, I've now submitted this:

https://review.gerrithub.io/346869

@stephens2424
Copy link
Author

Ah, that's right. Whoops :)

I'll have to take another look at my motivating example here, though, because I still suspect there's some problem in there. I was definitely giving that field a number, but kept getting that error. Or is there something else I'm missing that you also got stuck on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants