Thread
#general
    c

    curved-doctor-69226

    4 months ago
    Hi Community! I’m trying to test a Chart, but I keep getting this error:
    objects = json_opts.apply(lambda x: pulumi.runtime.invoke('kubernetes:helm:template',
    TypeError: 'NoneType' object is not subscriptable
    Could you help me out? Have someone tested a chart before? Thanks in advance!🧵
    This is the class I’m trying to test
    class HelmChart:
        def __init__(self, name: str, chart: str, repo: str, version: str):
            self.name = name
            self.chart = chart
            self.repo = repo
            self.version = version
    
            self.namespace = self._create_namespace()
            self.chart = self._create_chart()
    
        def _create_namespace(self) -> Namespace:
            return Namespace(f"{self.name}-ns", metadata=ObjectMetaArgs(name=self.name))
    
        def _create_chart(self) -> Chart:
            return Chart(
                f"{self.name}-chart",
                ChartOpts(
                    chart=self.chart,
                    version=self.version,
                    namespace=self.namespace.metadata.name,
                    fetch_opts=FetchOpts(
                        repo=self.repo,
                    ),
                )
            )
    And this is the test:
    @pulumi.runtime.test
        def test_chart(self):
            def check_chart(args):
                test_chart, = args
                self.assertIsNotNone(test_chart.chart)
    
            chart = HelmChart("test",
                              "test",
                              "test",
                              "test")
            return pulumi.Output.all(chart).apply(check_chart)
    And the mock:
    class TestMocks(pulumi.runtime.Mocks):
        def new_resource(self, args: pulumi.runtime.MockResourceArgs):
            return [args.name + '_id', args.inputs]
    
        def call(self, args: pulumi.runtime.MockCallArgs):
            return {}
    b

    billowy-army-68599

    4 months ago
    This is usually because you're trying to access an output value before it's resolved